head 头标签

DOCTYPE


HTML5

<!DOCTYPE html>

charset


声明文档使用的字符编码

<meta charset="utf-8">

lang属性


<html lang="zh-CN">
<html lang="en">

优先使用IE最新版本和Chrome


<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">

360浏览器


读取到这个标签后会立即切换对应的极速核

<meta name="renderer" content="webkit">

为了保险起见再加入上一种标签,如果安装了Google Chrome Frame,就使用GCF来渲染页面;如果没有安装 GCF,则使用最高版本的IE内核进行渲染。

禁止百度转码


<meta http-equiv="Cache-Control" content="no-siteapp">

SEO优化


页面标题title标签

<title>your title</title>

网页作者 author

<meta name="author" content="author, email address">

页面描述内容 description

<meta name="description" content="your description">

页面关键词 keywords

<meta name="keywords" content="your keywords">

Viewport


通常写成

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

width=device-width会导致在 iPhone 5 中网页被添加到主屏后,以WebApp全屏模式打开时出现黑边

content参数:

H5页面窗口自动调整到设备宽度,并禁止用户缩放页面

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

适配 iPhone 6 和 iPhone 6 plus

<meta name="Viewport" content="width=375">
<meta name="Viewport" content="width=414">

大部分 4.7~5 寸安卓设备的 Viewport 宽设为 360px,iPhone 6 为 375px

大部分 5.5 寸安卓设备(三星 Note)的 Viewport 宽为 400,iPhone 6 plus 为 414px

移动端字体


font-family: 中文字体使用系统默认字体,英文用Helvetica

font-size单位选择

  1. 只需要适配少部分手机设备,且分辨率对页面影响不大的,使用px

  2. 对于需要适配各种移动设备,使用rem,例如需要适配iPhone和iPad等分辨率差别比较大的设备

  3. rem配置参考:

html{font-size:10px}
@media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}}
@media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}}
@media screen and (min-width:415px) and (max-width:639px){html{font-size:15px}}
@media screen and (min-width:640px) and (max-width:719px){html{font-size:20px}}
@media screen and (min-width:720px) and (max-width:749px){html{font-size:22.5px}}
@media screen and (min-width:750px) and (max-width:799px){html{font-size:23.5px}}
@media screen and (min-width:800px){html{font-size:25px}

iOS 设备


添加到主屏后的标题

<meta name="apple-mobile-web-app-title" content="标题">

是否启用 WebApp 全屏模式

<meta name="apple-mobile-web-app-capable" content="yes">

设置状态栏的背景颜色,只有在"apple-mobile-web-app-capable" content="yes"时生效

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

content参数

禁止数字识自动别为电话号码

<meta name="format-detection" content="telephone=no">

iOS 图标


rel 参数

iPhone 和 iTouch,默认 57x57 像素

<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png">

iPad,72x72 像素

<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png">

Retina iPhone 和 Retina iTouch,114x114 像素

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png">

Retina iPad,144x144 像素

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png">

iPhone 6,120x120 像素;iPhone 6 plus,180×180 像素

<link rel="apple-touch-icon-precomposed" sizes="180x180" href="retinahd_icon.png">

iOS 启动画面


iPad 的启动画面不包括状态栏区域

<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png">
<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png">

iPhone 和 iPod touch 的启动画面包含状态栏区域

<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png">

iPhone 5/iPod Touch 5 竖屏 640x1136 (Retina)

<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png">

iPhone 6 竖屏 750×1294,iPhone 6 Plus 竖屏 1242×2148

<link rel="apple-touch-startup-image" href="launch6.png" media="(device-width: 375px)">
<link rel="apple-touch-startup-image" href="launch6plus.png" media="(device-width: 414px)">

添加智能 App 广告条 Smart App Banner(iOS 6+ Safari)

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

Windows 8


Windows 8 磁贴颜色

<meta name="msapplication-TileColor" content="#000">

Windows 8 磁贴图标

<meta name="msapplication-TileImage" content="icon.png">

rss订阅


<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml">

favicon icon


<link rel="shortcut icon" type="image/ico" href="/favicon.ico">

移动端meta


UC强制竖屏

<meta name="screen-orientation" content="portrait">

QQ强制竖屏

<meta name="x5-orientation" content="portrait">

UC强制全屏

<meta name="full-screen" content="yes">

QQ强制全屏

<meta name="x5-fullscreen" content="true">

UC应用模式

<meta name="browsermode" content="application">

QQ应用模式

<meta name="x5-page-mode" content="app">

Windows Phone 点击无高光

<meta name="msapplication-tap-highlight" content="no">
*****
From Web on 2015 Dec 01