📒
notebook
  • Notebook
  • DevOps
    • Git
      • 常见 Git 操作
      • 使用 SSH 连接 Git 远程仓库
      • 使用 GPG Keys 签名 Git 提交
      • Git on macOS
    • Docker
      • macOS 安装配置 Docker
      • CentOS7 安装配置 Docker CE
  • Linux
    • CentOS
      • CentOS7 安装配置 vsftpd
      • CentOS7 设置虚拟内存
      • CentOS7 使用 acme.sh 自动申请免费 SSL 证书
      • CentOS7 修改 SSH 端口号
      • CentOS7 主机初始设置
      • 阿里云 CentOS 主机常见设置
      • CentOS7 安装配置 SS
    • nginx
      • nginx 配置 301 永久重定向
      • nginx 使用 SSL证书配置 HTTPS
      • CentOS7 安装配置 nginx
      • nginx 配置 gzip 压缩
      • nginx 代理静态网页
  • Server
    • Ghost
      • macOS 安装配置 Ghost
      • CentOS7 安装配置 Ghost
    • npm & Yarn
      • Yarn 常用命令
      • CentOS7 安装卸载升级 Yarn
      • npm & Yarn 常见错误处理
      • macOS 安装卸载升级 Yarn
    • Node.js
      • Awesome Node.js
      • CentOS7 安装卸载升级 Node.js
      • macOS 安装卸载升级 Node.js
  • Web
    • Ionic
      • 创建 Ionic & Angular 项目
      • 使用 Ionic & Cordova 构建 Android 应用
      • macOS 搭建 Ionic & Cordova 开发环境
    • CSS
      • CSS 排版技巧
      • Awesome CSS
      • CSS 三栏自适应布局
    • Angular
      • Awesome Angular
      • 创建 Angular 项目
    • HTML
      • HTML head 常用标签
      • HTML 常用 DTD 声明
      • 常用网页语义结构
    • Web 技术标准
    • JavaScript
      • Awesome JavaScript
      • JavaScript 的 eval() 函数详解
  • Mobile
    • H5
      • iOS Safari Web App 配置
  • Development Environment
    • Development Utilities
      • Awesome Windows
      • macOS 安装配置 Homebrew
      • Awesome macOS
      • macOS 安装配置 iTerm2
    • FEED
      • 常用 Gulp 插件
  • Network
    • 常见公共 DNS
  • Technology Stacks for Web Front-End Development
Powered by GitBook
On this page
  • HTTP Headers 相关
  • 字符编码
  • 页面刷新
  • DNS 预解析
  • SEO 相关
  • 页面信息
  • 搜索引擎
  • 桌面浏览器兼容
  • 双核浏览器设置
  • IE9 以下浏览器
  • 移动设备适配
  • 移动视口适配
  • Safari 浏览器
  • QQ 浏览器
  • UC 浏览器
  • 百度移动适配
  • 链接外部资源
  • 参考文献

Was this helpful?

  1. Web
  2. HTML

HTML head 常用标签

PreviousHTMLNextHTML 常用 DTD 声明

Last updated 5 years ago

Was this helpful?

HTTP Headers 相关

字符编码

定义文档字符编码:

<!-- HTML5 -->
<meta charset="UTF-8" />

<!-- HTML4 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

Tips:

<meta> 元素必须包含在 <head> 元素中并且在HTML代码的前 1024 个字节内,因为某些浏览器在选择编码之前只查看前面这些字节。

<meta> 元素只是 t 中的一部分。 HTTP的 Content-Type 头部以及任何 Byte-Order Marks 元素都优先于此元素。

页面刷新

倒计时刷新页面:

<!-- 5s 后刷新页面 -->
<meta http-equiv="refresh" content="5" />

倒计时跳转页面:

<!-- 10s 后跳转到指定页面 -->
<meta http-equiv="refresh" content="10;url=https://github.com" />

DNS 预解析

开启 DNS 预解析,并指定预解析的域名:

<!-- 开启 DNS 预解析 -->
<meta http-equiv="x-dns-prefetch-control" content="on" />

<!-- 指定预解析的域名 -->
<link rel="dns-prefetch" href="https://github.com" />

SEO 相关

页面信息

页面标题:

<title>Title</title>

页面关键字(一般不超过 874 个字符):

<meta name="keywords" content="tagA,tagB,tagC" />

页面描述(一般不超过 150 个字符):

<meta name="description" content="About this site" />

搜索引擎

约定搜索引擎爬虫行为:

<!-- 页面可以被索引,页面上链接可以被追踪 -->
<meta name="robots" content="index,follow" />

<!-- 页面不可以被索引,页面上链接不可以被追踪 -->
<meta name="robots" content="noindex,nofollow" />

桌面浏览器兼容

双核浏览器设置

国内双核浏览器设置:

<!-- 默认使用 webkit 内核 -->
<meta name="renderer" content="webkit" />

<!-- 默认使用 IE 标准内核(取决于用户电脑的 IE 版本) -->
<meta name="renderer" content="ie-stand" />

<!-- 默认使用 IE 兼容内核(即 IE 6/7) -->
<meta name="renderer" content="ie-comp" />

IE9 以下浏览器

指定渲染模式:

<!-- 使用当前 IE 版本最高模式渲染 -->
<meta http-equiv="x-ua-compatible" content="ie=edge" />

<!-- 指定 IE 版本模式渲染 -->
<meta http-equiv="x-ua-compatible" content="ie=6" />

移动设备适配

移动视口适配

设置移动设备初始视口大小:

<!-- 页面宽度等于设备宽度,页面不缩放,禁止用户手动缩放 -->
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />

Safari 浏览器

关闭 iOS Safari (UIWebView) 自动识别:

<!-- 关闭数字自动识别为电话号码 -->
<meta name="format-detection" content="telephone=no" />

<!-- 关闭邮件地址识别 -->
<meta name="format-detection" content="email=no" />

Smart App Banner:

<!-- 在页面顶部显示对应的 App 的信息和 AppStore 下载地址 -->
<meta name="apple-itunes-app" content="app-id=MyAppStoreID,affiliate-data=MyAffiliateData,app-argument=MyAppURL" />

QQ 浏览器

QQ 浏览器设置:

<!-- QQ 强制竖屏 -->
<meta name="x5-orientation" content="portrait" />

<!-- QQ 强制全屏 -->
<meta name="x5-fullscreen" content="true" />

<!-- QQ 开启 WebApp 模式 -->
<meta name="x5-page-mode" content="app" />

UC 浏览器

UC 浏览器设置:

<!-- UC 强制竖屏 -->
<meta name="screen-orientation" content="portrait" />

<!-- UC 强制全屏 -->
<meta name="full-screen" content="yes" />

<!-- UC 开启 Web App 模式 -->
<meta name="browsermode" content="application" />

百度移动适配

移动端百度搜索结果跳转适配:

<!-- 禁止百度移动端搜索结果跳转时自动给页面转码 -->
<meta http-equiv="cache-control" content="no-siteapp" />

<!-- 百度移动端搜索到该结果时,会跳转到对应的移动页面 -->
<meta name="mobile-agent" content="format=html5;url=MobileWebUrl" />

链接外部资源

加载链接的外部资源:

<!-- 加载网站图标 -->
<link rel="icon" type="image/png" href="favicon.png">

<!-- 加载样式表 -->
<link rel="stylesheet" href="main.css" />

<!-- HTML5 加载可执行脚本 -->
<script src="main.js"></script>

<!-- HTML4 加载可执行脚本 -->
<script type="text/javascript" src="javascript.js"></script>

参考文献

algorithm to determine the character se
HTML(超文本标记语言)
meta
What does meta http-equiv=“X-UA-Compatible” content=“IE=edge” do?
Using meta tags to turn off caching in all browsers?
How to prevent caching in Internet Explorer
Promoting Apps with Smart App Banners