Meta tag migration from HTML 4.01 to HTML5

南笙酒味 提交于 2020-01-05 09:14:41

问题


We are looking at migrating over pages written in HTML 4.01 to HTML5 and am looking at the minimum requirements when including meta tags in the <head> element. For example, my current page which is HTML 4.01 compliant has the following meta tags:

<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="title" content="">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="created" content="2014-02-03T10:10:27.000-04:00">
<meta http-equiv="modified" content="2014-04-01T14:18:21.631-03:00">
<meta http-equiv="language" content="en">
<meta http-equiv="coverage" content="">
<meta http-equiv="publisher" content="">

My question is which one shoud be changed or removed and any other meta tag(s) need to be included.


回答1:


There are no required meta elements (with one exception, see below).

You can’t use just any metadata name (name) or pragma directive (http-equiv) like it was case in HTML 4.01. In HTML5, all values must be defined/registered in a certain manner.

So you’d have to check the spec and the wiki for possible values. If a value is not listed, don’t use it (or, if you are sure about it, register it).

Exception: there is a meta element that is sometimes required

Only if you don’t specify the character encoding in a different manner (e.g. in the Content-Type HTTP header), you must use a meta element for specifying it. See Specifying the document's character encoding.

If you use UTF-8, just add the following meta element (ideally as the first child element of head):

<meta charset="utf-8">


来源:https://stackoverflow.com/questions/25574042/meta-tag-migration-from-html-4-01-to-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!