元标记从HTML 4.01迁移到HTML5 [英] Meta tag migration from HTML 4.01 to HTML5

查看:86
本文介绍了元标记从HTML 4.01迁移到HTML5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在考虑将用HTML 4.01编写的页面迁移到HTML5,并且正在考虑在<head>元素中包含元标记时的最低要求.例如,我当前符合HTML 4.01的页面具有以下meta标签:

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.

推荐答案

没有必需的meta元素(一个例外,请参见下文).

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

您不能像HTML 4.01那样仅使用任何元数据名称(name)或编译指示(http-equiv). 在HTML5中,必须以某种方式定义/注册所有值 .

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.

因此,您必须检查规格和Wiki,以获取可能的值.如果未列出某个值,请不要使用它(或者,如果您确定要注册,请不要使用它).

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).

仅当您不以其他方式指定字符编码时(例如,在Content-Type HTTP标头中),才必须使用meta元素进行指定.请参见指定文档的字符编码 .

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.

如果使用UTF-8,只需添加以下meta元素(最好是head的第一个子元素):

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

<meta charset="utf-8">

这篇关于元标记从HTML 4.01迁移到HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆