2015-01-06 51 views
-2

我無法準確定位一段CSS文件來格式化HTML文件的一部分。將CSS協調爲HTML

我試圖讓tagline部分以綠色呈現,但是它呈現爲紅色。

這告訴我,這些樣式基於CSS的主體塊應用於本節。我如何獲得CSS tagline塊以應用於HTML的tagline部分?

這裏是HTML縮小:

<body> 
    <div id='container'> 
     <main> 
      <tagline> 
       bunch of text 
      </tagline> 
     </main> 
    </div> 
</body> 

這裏是CSS的相關部分: @CHARSET 「UTF-8」;

body, h1, h2, h3, h4, h5, h6, p, ul, dl, ol, form, fieldset, input, label, table, tbody, tfoot, th, tr, td, textarea, select 
{ 
    font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif; 
    font-weight: normal; 
    color: red; 
    font-size: 12px; 
} 

#container { 
    width:1280px; 
} 

// blue #5E91A8 <--these lines seem to be the problem! 
// green #C1D82F 

tagline { 
    font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif; 
    font-weight: normal; 
    font-size:16px; 
    color:green; 
} 

enter image description here

+2

'字體color'不存在,請使用'color' – user3790069

+1

應該是顏色,而不是字體顏色。 – Chad

+0

謝謝,但所有這些都錯過了標記。這不僅僅是顏色(我在帖子中改變了)。這是事實,我的CSS不匹配HTML文件的該部分。 – Alex

回答

1

只是color替換font-color

tagline 
 
{ 
 
    color: green; 
 
}
<body> 
 
    <div id='container'> 
 
     <main> 
 
      <tagline> 
 
       bunch of text 
 
      </tagline> 
 
     </main> 
 
    </div> 
 
</body>

0

的問題是與你的CSS。

要指定字體顏色,它只是color: red;color: green;。另外,刪除#red中的#。只有在指定數字的顏色時才需要#,即color: #ff0000;

body, h1, h2, h3, h4, h5, h6, p, ul, dl, ol, form, fieldset, input, label, table, tbody, tfoot, th, tr, td, textarea, select { 
     font-family:"Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif; 
     font-weight: normal; 
     color: red; 
     font-size: 12px; 
    } 
    #container { 
     width:1280px; 
    } 
    tagline { 
     font-family:"Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif; 
     font-weight: normal; 
     font-size:16px; 
     color:green; 
    } 

http://jsfiddle.net/79mjyjoq/

0

這是因爲元件繼承了更高水平的性能。你將不得不重寫屬性,像這樣:

tagline{ color:red; } 
0

HTML不知道tagline元素。但HTML5確實支持自定義元素。

通過指定自定義元素的名稱應該包含' - '。因此,這將在所有現代瀏覽器的工作:

<!DOCTYPE html> 
<html> 
    <head> 
    <title></title> 
    <style> 

     tag-line { 
     color:green; 
     }  

    </style> 
    </head> 
<body> 
    <div id='container'> 
      <tag-line> 
       bunch of text 
      </tag-line> 
    </div> 
</body> 
</html> 
+0

它確實知道'main':http://www.w3.org/TR/html5/grouping-content.html#the-main-element – user3790069

+0

oops,你是對的,主要在那裏。 –

+0

奇怪的是一些解析器會把它:) Stack Snippet將該樣式應用於標語:) – sodawillow