推荐的元元素?

发布于 2024-09-02 10:09:38 字数 1018 浏览 4 评论 0原文

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

<!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>

PS“内容语言”=“语言”?

Setting up a "basic framework" for my website projects, I'm wondering which meta elements are really necessary/recommended? In particular, I'd like to know how to deal with the language attribute(s)!? In the following example, I think sth. is repeated unnecessarily...

<!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>

P.S. "content-language" = "language"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

才能让你更想念 2024-09-09 10:09:38
<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" />

冗余

<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" />

由于广泛滥用而被每个搜索​​引擎忽视。

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

Definitely recommended

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

Useless, browsers only support CSS.

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

Useless, browsers only support JavaScript.

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

Redundant to <html lang="en">

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

Doesn't exist, AFAIK.

<title> Title </title>

Definitely recommended.

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

Depends on how you want your relative links to work, I suppose.

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

Look like typo's.

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

Probably useful.

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

Ignored by every search engine due to widespread abuse.

年华零落成诗 2024-09-09 10:09:38

将其用于 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-tag 之后:

<!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>

Use this for HTML 5:

<!DOCTYPE html>

This looks wrong:

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

should probably be this for HTML 5:

<meta charset="utf-8">

That is the new HTML 5-way of setting charset encoding. It is highly recommended to also include the old way:

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

These should be directly after the opening head-tag:

<!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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文