html5 移动适配写法

在pc版网页(http://pc_url) 上,添加:

<link rel="alternate" media="only screen and(max- 640px)" href="http://pc_url" >

在移动版网页(http://mobile_url) 上,所需的注释应为:

<link rel="canonical" href="http://mobile_url" >

之前的Meta标记(mobile agent)会继续沿用,但我们推荐使用HTMAL5语言制作的移动页面使用最新方案进行跳转适配,其它如xml语言的移动页跳转适配,需要继续使用之前的meta标记方式:

<meta name="mobile-agent"content="format=[wml|xhtml|html5]; url=mobile_url">

html5新增的移动适配写法如上,这个主要是为了百度等搜索引擎抓取到网站的移动端网址是什么,不是自动当设备切换到手机时自动跳转的.若实现自动跳转还需要js.

参考:http://www.cnblogs.com/osfipin/p/5852037.html

原文地址:https://www.cnblogs.com/beileixinqing/p/7778541.html