推荐的元标签是什么?

8

为我的网站项目建立“基本框架”,我想知道哪些元素是真正必要/推荐的?特别是,我想知道如何处理语言属性!在下面的例子中,我认为有些内容被不必要地重复了...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-language" content="en" />
<meta http-equiv="language" content="en" />

<title> Title </title>
<base href="http://www.mydomain.com" />

<meta name="charset" content="utf-8" />
<meta name="content-language" content="en" />
<meta name="language" content="en" />

<meta name="description" content="description" />
<meta name="keywords" content="keywords" />

</head>

附注:“content-language”=“language”吗?


请问,我在自己的网站上必须放哪些重要的元标签? - Dheeraj Vepakomma
2个回答

14
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

绝对推荐

<meta http-equiv="content-style-type" content="text/css" />

无用的,浏览器只支持 CSS。

<meta http-equiv="content-script-type" content="text/javascript" />

无用的,浏览器只支持JavaScript。

<meta http-equiv="content-language" content="en" />

<html lang="en">

的语言属性是英语,因此使用它是多余的。

<meta http-equiv="language" content="en" />

据我所知,不存在这样的东西。

<title> Title </title>

强烈推荐。

<base href="http://www.mydomain.com" />

我想这要取决于你希望相对链接如何工作。

<meta name="charset" content="utf-8" />
<meta name="content-language" content="en" />
<meta name="language" content="en" />

看起来像是笔误。

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

可能会有用。

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

由于广泛的滥用,被每个搜索引擎忽略。


1
使用此代码适用于HTML 5:
<!DOCTYPE html>

这看起来不对:

<meta name="charset" content="utf-8" />

HTML 5 应该是这样的:

<meta charset="utf-8">

这是新的 HTML 5 设置字符集编码的方式。强烈建议同时包含旧的方式:

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

这些应该直接放在开头head标签后面:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>The title</title>
    </head>
    <body>
    </body>
</html>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接