我知道,h1標籤是搜索引擎優化的重要,所以我所有的標題是H1(好樣的!)h1標籤類(備用)
現在,我需要有一個標題(如文本的第一行)在一些頁面上有點不同。
通常,我只是複製h1作爲h2和備用。
的問題是:是否有可能一個類添加到標題標籤...(我已經嘗試沒有成功)
我知道,h1標籤是搜索引擎優化的重要,所以我所有的標題是H1(好樣的!)h1標籤類(備用)
現在,我需要有一個標題(如文本的第一行)在一些頁面上有點不同。
通常,我只是複製h1作爲h2和備用。
的問題是:是否有可能一個類添加到標題標籤...(我已經嘗試沒有成功)
,您可以:
<h1 class="someclass">…</h1>
的class
attribute是在可與h1
element使用的attribute group coreattrs of core attributes 。
您可以類添加到<h1>
標籤。就像這樣:
<h1 class="myclass"> ... </h1>
您可以輕鬆風格像這樣:當然
<style type="text/css">
.myclass { color : green }
</style>
<標題>標記位於您的< head>部分中,所以向它添加類是沒有意義的。
不過,您可以將類添加到您的< h1>標記中。
<h1 class="title">
您可以風格像這樣的標題:
h1 { color: red; }
或者這樣:
<h1 class="fancy">Fancy</h1>
.fancy { font-family: fantasy; }
如果它不工作:
編輯:
這聽起來像你有h1 .myClass
,而不是h1.myClass
- 有一個重要的區別:
h1 .myClass { } /* any element with class="myClass" within an <h1> */
h1.myClass { } /* any <h1> with class="myClass" */
下面應該工作:
<html>
<head>
<style type="text/css">
h1.custom {
color: red;
font-size: 16px;
}
</style>
</head>
<body>
<h1 class="custom"> test </h1>
</body>
</html>
I聽起來就像你在頁面上使用h1
的所有標題。通常,頁面上會包含一個h1
標籤,其中包含文本至少部分與頁面標題匹配的內容,以及內容不同部分標題的較小標題標籤。這樣,您可以向搜索引擎提供有關頁面上重要內容的大部分信息。當然有些頁面不適合這種模式,但很多都可以。
有許多不同的方法可以爲標題指定樣式。例如:
對於所有h1
標籤:
h1 { font-weight: bold; }
對於所有h1
和h2
標籤:
h1, h2 { margin: 10px; }
對於元件內部的所有h1
標籤與id="main"
:
#main h1 { background: #ccc; }
全部h2
個標籤與class="Info"
:
h2.Info { color: #000; }
一個元素內的所有h3
標籤與class="More"
:
.More h3 { text-decoration: underline; }
<div class='row' id='content-wrapper'>
<div class='clear'/>
<b:if cond='data:blog.pageType == "error_page"'>
<div id='error-wrap'>
<h1 class='error-item'>404</h1>
<h2>Page Not Found!</h2>
<p>Sorry, the page you were looking for in this blog does not exist.</p>
<div class='clear'/>
<a class='homepage' expr:href='data:blog.homepageUrl'><i class='fa fa-home'/> Go To Home</a>
</div>
添加一些解釋並回答這個答案如何幫助OP修復當前問題 – 2017-11-11 22:39:05
請發表您的代碼或網址。 – Asaph 2009-11-12 21:19:22
我已經嘗試跨度,但它爬上邊緣/填充 – menardmam 2009-11-12 21:20:16