2016-07-01 75 views
-1

這是我的代碼,所以具有p#01 id屬性的格式根本沒有顯示(我想爲該元素的文本指定特定的像素和顏色),發生了什麼?如何修復ID屬性:爲什麼不顯示?

<!DOCTYPE html> 
<html> 
    <head> 
    <style> 
     p.error { 
     color: red; } 
     p#01 { 
     border:1px solid red; 
     padding:10px; 
     margin:5px; 
     color:blue; } 
    </style> 
    </head> 

<p>This is a paragraph.</p> 
<p>This is a paragraph.</p> 
<p class="error">I am different.</p> 
<p>This is a paragraph.</p> 
<p class="error">I am different too.</p> 
<p id="p01">Tell me what is love</p> 

+4

'id =「p01」'vs'p#01'。您的CSS選擇器與HTML標識不匹配。 – lonesomeday

+1

使用'#p01'而不是'p#01' – Alexis

+0

謝謝,它的工作! – ELovesPuppy

回答

0

HTML代碼:

<p>This is a paragraph.</p> 
<p>This is a paragraph.</p> 
<p class="error">I am different.</p> 
<p>This is a paragraph.</p> 
<p class="error">I am different too.</p> 
<p id="p01">Tell me what is love</p> 

CSS代碼:

p.error { 
color: red; } 
p#p01 { 
border:1px solid red; 
padding:10px; 
margin:5px; 
color:blue; } 

演示fiddle

HTML中使用的id="p01"與CSS中使用的不匹配。

相關問題