首页 > 其他分享 >HTML 12 - Meta Tags

HTML 12 - Meta Tags

时间:2024-05-18 15:30:11浏览次数:11  
标签:12 your HTML Meta Tags page tag Example

 

HTML lets you specify metadata, which is additional important information about a document, in a variety of ways. The META elements can be used to include name/value pairs describing properties of the HTML document, such as author, expiry date, a list of keywords, document author etc.

The <meta> tag is used to provide this extra information. It's a self-closing element, meaning it doesn't require a closing tag but carries information within its attributes.

You can include one or more meta tags in your document based on what information you want to keep in your document but in general, meta tags do not impact the physical appearance of the document so from the appearance point of view, it does not matter if you include them or not.

Adding Meta Tags to Your Documents

You can add metadata to your web pages by placing <meta> tags inside the header of the document which is represented by <head> and </head> tags. A meta tag can have following attributes in addition to core attributes −

S.NoAttribute & Description
1

Name

Name for the property. Can be anything. Examples include, keywords, description, author, revised, generator etc.

2

content

Specifies the property's value.

3

scheme

Specifies a scheme to interpret the property's value (as declared in the content attribute).

4

http-equiv

Used for http response message headers. For example, http-equiv can be used to refresh the page or to set a cookie. Values include content-type, expires, refresh and set-cookie.

Specifying Keywords

You can use <meta> tag to specify important keywords related to the document and later these keywords are used by the search engines while indexing your webpage for searching purposes.

Example

Following is an example, where we are adding HTML, Meta Tags, and Metadata as important keywords about the document.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

Document Description

You can use <meta> tag to give a short description about the document. This again can be used by various search engines while indexing your webpage for searching purpose.

Example

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

Document Revision Date

You can use <meta> tag to give information about when last time the document was updated. This information can be used by various web browsers while refreshing your webpage.

Example

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

Document Refreshing

A <meta> tag can be used to specify a duration after which your web page will keep refreshing automatically.

Example

If you want your page keep refreshing after every 5 seconds then use the following syntax.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
   <meta http-equiv="refresh" content="5" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>
 

Page Redirection

You can use <meta> tag to redirect your page to any other webpage. You can also specify a duration if you want to redirect the page after a certain number of seconds.

Example

Following is an example of redirecting current page to another page after 5 seconds. If you want to redirect page immediately then do not specify content attribute.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
   <meta http-equiv="refresh" content="5; url=http://www.tutorialspoint.com" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

The above program will redirect you to Tutorialspoint home page after 5 seconds.

Setting Cookies

Cookies are data, stored in small text files on your computer and it is exchanged between web browser and web server to keep track of various information based on your web application need.

You can use <meta> tag to store cookies on client side and later this information can be used by the Web Server to track a site visitor.

Example

 

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
   <meta http-equiv="cookie" content="userid=xyz; expires=Wednesday, 08-Aug-15 23:59:59 GMT;" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

If you do not include the expiration date and time, the cookie is considered a session cookie and will be deleted when the user exits the browser.

Note − You can check PHP and Cookies tutorial for a complete detail on Cookies.

 

Setting Author Name

You can set an author name in a web page using meta tag. See an example below −

Example

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="author" content="Mahnaz Mohtashim" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

Specify Character Set

You can use <meta> tag to specify the character set used within the webpage.

Example

By default, Web servers and Web browsers use ISO-8859-1 (Latin1) encoding to process Web pages. Following is an example to set UTF-8 encoding −

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="author" content="Mahnaz Mohtashim" />
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

To serve the static page with traditional Chinese characters, the webpage must contain a <meta> tag to set Big5 encoding −

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="author" content="Mahnaz Mohtashim" />
   <meta http-equiv="Content-Type" content="text/html; charset=Big5" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

 

 

 

标签:12,your,HTML,Meta,Tags,page,tag,Example
From: https://www.cnblogs.com/emanlee/p/18190422

相关文章

  • HTML 11 - Phrase Tags
     Thephrasetagshavebeendesignedforspecificpurposes,thoughtheyaredisplayedinasimilarwayasotherbasictagslike<b>,<i>,<pre>,and<tt>,asyouhaveseeninthepreviouschapter.Thischapterwilltakeyouthrough......
  • 在debian12上安装kvm的虚拟机
     主要参考:    https://wiki.debian.org/KVM#Installation     https://cloud-atlas.readthedocs.io/zh-cn/latest/kvm/libvirt/virt-install_location_iso_image.html  创建vm时使用的命令:      virt-install--namedebian\--os-variantdebian......
  • 【日记】母亲生日,我在跟数字人民币 Battle(612 字)
    正文昨天跟奇安信Battle,今天跟数字人民币Battle。鬼知道数字人民币客户端怎么写的,我弄了一天,隐藏Root,禁止读取应用列表,权限开放,用另一个手机或iPad登陆,都不行。全在提示“检测到环境异常,暂无法提供数字人民币服务”。最后给我逼急了,用另外两个同事手机登陆,也提示......
  • HTML 10 - Comments
    HTMLCommentsareusedtocommentinHTMLcodes,sothedevelopercanunderstandthepurposeofthatcodesectionanditishelpfullfordebuggingalso.Ifwearefacingsomeissuebecouseofanyparticularelementwecahcheckitbycommentingoutthate......
  • HTML 09 - Quotations
     QuotationsinHTMLallowyoutoincludeandformatquotedtextwithinyourwebcontent.HTMLprovidestagssuchas<blockquote>,<q>,<cite>,<address>,<bdo>and<abbr>tostructureandstylequotes.Thesetagshelp......
  • P10125 「Daily OI Round 3」Simple 题解
    题目传送门简单模拟,主要考察字符串。首先输入一个char类型的数组,然后直接遍历每一位是否为Acoipp或Svpoll即可。//Simple//codeby:cq_irritater//time:2024/02/04#include<bits/stdc++.h>usingnamespacestd;chara[10];intmain(){//freopen("......
  • C122 李超树合并+DP CF932F Escape Through Leaf
    视频链接:C122李超树合并+DPCF932FEscapeThroughLeaf_哔哩哔哩_bilibili   C65【模板】线段树合并P4556[Vani有约会]雨天的尾巴-董晓-博客园(cnblogs.com)CF932FEscapeThroughLeaf#include<iostream>#include<cstring>#include<algorithm>using......
  • 122- Best Time to Buy and Sell Stock II 卖股票II
    题目描述链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/Youaregivenanintegerarraypriceswhereprices[i]isthepriceofagivenstockontheithday.Oneachday,youmaydecidetobuyand/orsellthestock.Youcanon......
  • 012_尚硅谷_Windows下搭建Go开发环境
    1.Windows下搭建Go开发环境-安装和配置SDK1.1介绍SDK1)SDK(软件开发工具包)2)SDK是提供给开发人员使用的,其中包含了对应开发语言的工具包1.2SDK下载1)下载地址:Golang中国  https://go.p2hp.com/go.dev/dl/2)如何选择对应的SDK......
  • HTML5中 drag 和 drop api
    被拖放元素--A,目标元素--B。dragstart事件主体是A,在开始拖放A时触发。dragend事件主体是A,在整个拖放操作结束时触发。drag事件主体是A,正在拖放A时触发(整个拖拽,drag事件会在被拖拉的节点上持续触发,相隔几百毫秒)。dragenter事件主体是B,在A进入某元素的时候触发。drago......