HTML | meta元信息

发布时间 2023-08-02 16:22:41作者: 张Zong在修行

HTML <meta> 元素表示那些不能由其他 HTML 元相关(meta-related)元素表示的元数据信息。如:<base><link><script><style><title>

  1. 配置字符编码
<meta charset="utf-8">
  1. 针对 IE 浏览器的兼容性配置。
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  1. 针对移动端的配置(移动端课程中会详细讲解)
<meta name="viewport" content="width=device-width, initial-scale=1.0">
  1. 配置网页关键字
<meta name="keywords" content="8-12个以英文逗号隔开的单词/词语">
  1. 配置网页描述信息
<meta name="description" content="80字以内的一段话,与网站内容相关">
  1. 针对搜索引擎爬虫配置:
<meta name="robots" content="此处可选值见下表">
描述
index 允许搜索爬虫索引此页面。
noindex 要求搜索爬虫不索引此页面。
follow 允许搜索爬虫跟随此页面上的链接。
nofollow 要求搜索爬虫不跟随此页面上的链接。
all index, follow 等价
none noindex, nofollow 等价
noarchive 要求搜索引擎不缓存页面内容。
nocache noarchive 的替代名称。
  1. 配置网页作者:
<meta name="author" content="tony">
  1. 配置网页生成工具
<meta name="generator" content="Visual Studio Code">
  1. 配置定义网页版权信息:
<meta name="copyright" content="2023-2027©版权所有">
  1. 配置网页自动刷新
<meta http-equiv="refresh" content="10;url=http://www.baidu.com">

完整的网页元信息,请参考:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/meta

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- 配置字符编码 -->
    <meta charset="UTF-8">
    <!-- 针对IE浏览器的一个兼容性设置 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 针对移动端的一个配置 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 配置网页的关键字 -->
    <meta name="keywords" content="网上购物,电商购物,皮鞋,化妆品">
    <!-- 配置网页描述信息 -->
    <meta name="description" content="哈哈购物网成立于2003年,致力于打造国内优质的电商购物平台....">
    <!-- 自动刷新 -->
    <meta http-equiv="refresh" content="3">
    <title>meta元信息</title>
</head>
<body>
    <h1>你好啊</h1>
</body>
</html>