首页  >  文章  >  web前端  >  HTML 中的元标记

HTML 中的元标记

WBOY
WBOY原创
2024-09-04 16:20:50469浏览

HTML 中的元标记用于定义有关网页或 HTML 文档的数据。借助元标记,可以定义文档的描述、上次更新时的作者信息;它用于给出 HTML 文档的详细属性。元标记在 中定义。 HTML 标签,包含在

中部分。对于网页设计者来说,显示网页的实际显示部分是最有用的。整个视口控制将由他们使用 HTML 5 中的元标记来完成。大多数浏览器都会引用元标记来实现许多有用的功能,例如刷新页面、显示网页内容以及它们使用的 Web 服务。

语法

head 部分使用的元标记如下:

<meta charset="utf-8">

在上面的语法中,它指出 charset=”utf-8” 为显示任何类型的语言提供了最佳支持。
这是具有某些值的元标记的另一种语法是:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

它用于处理视口的大小及其所有页面尺寸值和页面滚动,以完美地适应我们的网页在任何类型的设备上。

HTML 中的元标记列表

HTML 中使用了不同类型的 Meta 标签;我们来一一看看:

1。 这是一个非常基本的元标记,用于定义任何类型的语言。

2。  用于定义最多 150 个单词的内容描述。

3。  用于保留所定义公司的所有版权。

4。  用于定义特定网页的摘要。

5。  它用于定义 HTML 文档的作者。

6。 <元名称=”url”内容=”http://www.websiteaddrress.com”> 用于定义标签属性中定义的特定公司的URL地址。

7。  它用于处理我们文档中的评级。

8。  如果我们想为 HTML 文档定义副标题,那么可以使用此标签。

9。  它用于在指定的时间刷新我们的网页垃圾邮件。

10。  它用于按定义的实体值对我们的文档进行分类。

11。  这个标签用来指定Meta标签中的一些关键词,这样就可以在我们的文档中轻松搜索到这些内容。

12。  此标签用于定义我们文档的摘要。

HTML 中元标记的工作

HTML中的Meta标签主要用于在我们的网页文档中包含机器可读的信息,这些信息在网页上实际上是不可见的。这个标签在 HTML 中的另一个最重要的工作是,借助这个标签,人们可以使用这个元标签功能轻松重定向到另一个网页。

元标记可以正常工作的一些属性列表如下:

1。内容: 元标记中的内容就像其包含的元标记的值一样。

2。名称: 名称用作元标记的属性。它以详细信息、所有者、关键字等形式出现。

3。 http-equiv: 该属性用于定义文档中的标头详细信息。

4。 Charset: 它是 Meta 标签中的主要属性,用于定义字符编码以在其文档中进行声明。

5。方案: 该属性用于定义将使用实际元标记的方案。但 HTML5 不支持这种类型的属性。

HTML 中元标记的示例

让我们看一些例子

示例#1

我们将使用Meta标签,它会被计算机系统读取,但网页的访问者看不到任何内容。

HTML 代码:

<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Meta tag details information here">
<meta name="robots" content="Robotics"/>
<meta name="hotmail:card" content="summary"/>
</head>
</html>

输出:它将显示空白屏幕作为输出。

HTML 中的元标记

Example #2

Here is this example we are going to use different kinds of Meta tags and show the output; the web page will be refresh at every specific time and store cookies for your page, also mentioning its expiry date.

HTML code:

<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta http-equiv = "cookie" content = "userid = xyz;
expires = Tuesday, 31-Dec-19 23:59:59 IST;" />
<meta name = "revised" content = "EDUCBA -Online courses, 3/7/2019" />
<meta http-equiv = "refresh" content = "5" />
</head>
<body>
<h1>EDUCBA</h1>
<h2>Become an Awesome Design Expert</h2>
<p>EDUCBA- All about online certification courses</p>
<h4>Learn Graphic designing, Animation, Game Development, Video Editing & more with our Online Certification Courses</h4>
<p>Choose your interest area and get certified with our online Courses in Finance, Data Science, Software Development, Excel, Design, Project Management, Personal Development, Marketing and Human Resources.</p>
</body>
</html>

Output: The webpage shown in output will refresh every 5 seconds.

HTML 中的元标记

Example #3

Let’s see another example using meta tags, it will reflect the same as above, but after refreshing the webpage, it will redirect to another webpage which URL’s will be mentioned in the Meta tag as shown in the below HTML code:

HTML code:

<head>
<title>Meta Tags in HTML 5</title>
<meta name = "keywords" content = "HTML 5, Meta Tag" />
<meta name = "description" content = "Detail description of Meta Tags in
HTML 5."/>
<meta http-equiv = "refresh" content = "10; url = https://www.educba.com/" />
</head>
<body>
<p>EDUCBA- All about online certification courses</p>
</body>

Output:

HTML 中的元标记

HTML 中的元标记

Conclusion

So, a Meta tag in Html is used to define metadata about HTML documents. The code included in it is a machine-readable format that works well with a webpage but doesn’t show any content on the page to the visitors. Meta tag containing 3 different types of attributes like global, element-specific, and event handler attributes.

以上是HTML 中的元标记的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
上一篇:HTML Table Tags下一篇:Caption Tag in HTML