ID属性:为什么它没有显示?

时间:2016-07-01 09:59:35

标签: html css

这是我的代码,所以p#01 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>

1 个答案:

答案 0 :(得分: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中使用的p#01不匹配。