<meta>
标签常用属性列表
属性 | 值 | 说明 |
---|---|---|
charset | utf-8 , iso-8859-1 , 等等 | 定义HTML文档的字符编码。 |
name | description , keywords , author , viewport , 等等 | 定义与文档相关的元数据的名称。 |
content | 与 name 属性结合使用的任意字符串 | 提供与 name 属性相关的内容。 |
http-equiv | content-type , default-style , refresh , 等等 | 将内容作为HTTP头部信息发送给服务器。 |
scheme | 与 name 属性结合使用的任意字符串 | 定义元数据的方案(很少使用)。 |
property | 与 og (Open Graph)相关的属性 | 用于定义Open Graph协议的元数据,通常用于社交媒体平台。 |
charset
属性指定HTML文档的字符编码。
设置文档的字符编码,确保文档中的字符正确显示。
值 | 说明 |
---|---|
utf-8 | UTF-8字符编码(最常用)。 |
iso-8859-1 | ISO-8859-1字符编码(西欧)。 |
windows-1252 | Windows-1252字符编码。 |
gb2312 | GB2312字符编码(简体中文)。 |
<meta charset="utf-8">
name
和 content
属性name
属性定义元数据的名称,content
属性提供与名称相关的内容。
定义与文档相关的各种元数据,如描述、关键词、作者、视口设置等。
值 | 说明 |
---|---|
description | 网页的简短描述,搜索引擎会在搜索结果中显示。 |
keywords | 与网页内容相关的关键词(现已不常用)。 |
author | 网页的作者信息。 |
viewport | 设置视口的属性,常用于响应式设计。 |
robots | 指示搜索引擎如何索引页面。 |
theme-color | 定义浏览器工具栏的颜色。 |
application-name | 定义网页应用的名称。 |
<meta name="description" content="A brief description of the webpage.">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="Author Name">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#ffffff">
<meta name="application-name" content="MyApp">
http-equiv
和 content
属性http-equiv
属性将内容作为HTTP头部信息发送给服务器。
设置文档的HTTP头部信息,如字符集、刷新频率、缓存控制等。
值 | 说明 |
---|---|
content-type | 指定文档的MIME类型和字符编码。 |
default-style | 指定文档的默认样式表。 |
refresh | 指示浏览器在指定的时间间隔后刷新页面。 |
cache-control | 控制浏览器的缓存行为。 |
expires | 指定文档的到期时间。 |
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="30">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="Wed, 21 Oct 2020 07:28:00 GMT">
property
和 content
属性(Open Graph 协议)property
属性用于定义Open Graph协议的元数据,通常用于社交媒体平台。
提供社交媒体分享时使用的元数据,如标题、描述、图片URL等。
值 | 说明 |
---|---|
og:title | 在社交媒体分享时使用的页面标题。 |
og:description | 在社交媒体分享时使用的页面描述。 |
og:image | 在社交媒体分享时使用的图片URL。 |
og:url | 在社交媒体分享时使用的页面URL。 |
og:type | 在社交媒体分享时定义内容类型(如website ,article )。 |
og:site_name | 网站的名称。 |
<meta property="og:title" content="The Title of the Page">
<meta property="og:description" content="A description of the page for social media sharing.">
<meta property="og:image" content="http://example.com/image.jpg">
<meta property="og:url" content="http://example.com">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Example Site">