2010-05-20 75 views
8

爲我的網站項目設置一個「基本框架」,我想知道哪些元素是真的必要/推薦?特別是,我想知道如何處理語言屬性(S)!?在下面的例子中,我想。不必要地重複...推薦元數據?

<!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」=「語言」?

+0

http://stackoverflow.com/questions/1092329/what的重複:

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

這些應該開幕頭標記後直接-are-the-important-meta-tags-i-must-put-in-my-website – 2012-02-07 11:17:36

回答

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

由於廣泛濫用而被每個搜索​​引擎忽略。

+0

謝謝,ms2ger! – joyce 2010-05-21 02:06:01

1

使用此爲HTML 5:

<!DOCTYPE html> 

這看起來錯:

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

也許應該是這對HTML 5:

<meta charset="utf-8"> 

這是新的HTML 5設置字符集編碼的方式。強烈建議也包括舊的方式:

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