2010-12-02 34 views
0

第8行,第7列:省略「STYLE」的結束標記,但其聲明不允許此 ✉ •您忘記關閉標記,或 •您在此標籤內使用了不允許的內容,並且驗證程序在抱怨應在標籤允許之前關閉標籤。 下一條消息,「開始標記在這裏」指向所討論標記的特定實例);位置指示器指向驗證器期望您關閉標籤的位置。 7號線,1列:開始標記在這裏 當我嘗試驗證文件時,CSS格式化給我一個錯誤

<html> 
<head> 
<title>Randy's first html web page !</title> 
<style type="text/css"> 
</head> 
body 
h1 
{ 
background-color:#6495aa; 
margin-right:1350px; 
} 
h2 
{ 
background-color:#b0c4de; 
margin-right:1350px; 
} 
p 
{ 
background-color:#649fff; 
margin-right:1350px; 
} 
div 
{ 
background-color:#efffff; 
} 
</style> 

回答

3

你自己的風格之前關閉你的頭,所以驗證器把它看作你已經有<style>完成,並認爲你忘記關閉</head>之前,請嘗試:

<html> 
<head> 
<title>Randy's first html web page !</title> 
<style type="text/css"> 
body 
h1 
{ 
background-color:#6495aa; 
margin-right:1350px; 
} 
h2 
{ 
background-color:#b0c4de; 
margin-right:1350px; 
} 
p 
{ 
background-color:#649fff; 
margin-right:1350px; 
} 
div 
{ 
background-color:#efffff; 
} 
</style> 
</head> 

還,我看到

body 
h1 
{ 
... 

是故意的嗎?

+0

是得到它謝謝 – user770022 2010-12-02 04:17:52

1

你太早關閉了<head>標籤。另外,如果你想驗證你的文件XHTML,您可能需要您的包裹內聯樣式在CDATA標籤,像這樣:

<style type="text/css"> 
<![CDATA[ 
/* CSS goes here */ 
]]> 
</style> 

Source of the XHTML tip

相關問題