2012年10月5日 星期五

如何美化網頁文字(5)-[font-style]文字粗體斜體設定方式


在粗體和斜體的設定中,斜體有<em>及<i>,<em>表示強調內容,<i>表示斜體字,粗體有<h1>~<h6>、<strong>、<th>、<b>,<h1>~<h6>為標題標籤,<strong>為重要內容,<th>為表格標題標籤,<b>為粗體字,可用以上的方式表達粗體及斜體。
而要注意的一點是<b>、<i>標籤,此兩種標籤已在新版的html5中,以列為建議不再使用之標籤,因為設為此標籤之內容,無法表達文章的意義,當你要提示內文的重點時,還是用<strong>和<em>較為好,這樣對你的網頁在被搜尋時,更容易被找到。
橙先寫html 吧!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>魚和橙</title>
</head>
<body>

<articleclass="a1">
  <h1>this is my font style</h1>
  <p>The results of a survey <strong>keyword</strong> Friday showed <span>that 70 percent</span> of local <em>salaried employees</em> are hesitant(1) about getting married, citing insufficient(2) savings and job instability as the reasons. </p>
</article>

</body>
</html>
 先看結果唄!
2012-10-05_122148        
為了看不清楚,我把網頁放大,這樣看得比較明顯,在使用該標籤時,該位置就會出現斜體和粗體了。用<strong>和<em>也可以和google & Bing 說這個內文對我的網頁是很重要的,而<b>和<i>卻無法如此告知。
再來,各位有發現有一個<span>的標籤,<span>的標籤可以用在內文中內的任何地方,而我們可以利用他用css 來設定 粗體和斜體的部份,橙來加入css吧!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>魚和橙</title>
<style type="text/css">
 span {
    font-size: 18px;
    font-style: italic;
    font-weight: bold;
}
</style>
</head>
<body>
<articleclass="a1">
  <h1>this is my font style</h1>
  <p>The results of a survey <strong>keyword</strong> Friday showed <span>that 70 percent</span> of local <em>salaried employees</em> are hesitant(1) about getting married, citing insufficient(2) savings and job instability as the reasons. </p>
</article>
</body>
</html>
 橙將全部html + css 的部份在列表出來,有人問了css要寫在哪?就是寫在<style type="text/css"> ....  </style> 裡面;
 回到主題,我將1.<span>的字型大小設為18px,2.設斜體-font-syle:italic ,3.設粗體- font-weight:bold ,這樣就可以完成粗體和斜體的設定了
 來看結果吧!
2012-10-05_123721
結果就會和你設定的一樣的方式出現,而這樣的設定可以用在各種標籤中,此例中,只是用<span>來表示而已(因為常用),而還有如果在父類已設定成了粗體或斜體,而你想要他的子類並不須要粗體或斜體時,記得要像如下設定:
粗體解除:
font-weight:normal;
斜體解除:
font-style:normal;
這樣就可解除了,各位可以試試看吧! 

沒有留言:

張貼留言