iT邦幫忙

2025 iThome 鐵人賽

DAY 9
0
Modern Web

HTML&CSS30天修煉系列 第 9

day9Html文字樣式

  • 分享至 

  • xImage
  •  

HTML裡有許多方法可以改變類似p標籤等的文字內容,讓顯示方式更加多元
font-style:italic讓文字呈現斜體

<p style="font-style: italic;">This is a paragraph with bold text.</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696s7tBXTsDOQ.png
font-weight:設定字體粗細
font-weight:normal字體默認粗細
font-weight:bolder比父元素粗
font-weight:bold粗體
font-weight:lighter比父元素細

        <p style="font-weight:normal">normal</p>
        <p style="font-weight:bolder">bolder</p>
        <p style="font-weight: bold;">bold</p>
        <p style="font-weight: lighter;">lighter</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696gepYPu7UFF.png
另外font-weight也可以設定數字,可以看到100到500之間沒有任何差別,到600才變粗,這是字型的原因,如果字型當初沒有設計那麼多粗細差別的話,那麼你再怎麼設定也沒有用

        <p style="font-weight:100">100</p>
        <p style="font-weight:300">300</p>
        <p style="font-weight: 500;">500</p>
        <p style="font-weight: 600;">600</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696g2HNcuizXW.png
font-family:改變字形

<p style="font-family: 'Franklin Gothic Medium'">被font-family改字形</p>

https://ithelp.ithome.com.tw/upload/images/20250923/201786966aGymA9NAl.png
font-family可以設定複數字形,當無法找到第一個字形時就會去找第二個

   <p style="font-family:'Franklin', 'Courier New'">被font-family改字形</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696eFuYLKDUNb.png

之前在超連結提過text-decoration:none刪除a的底線,其實還能做更多的事情
text-decoration:overline給文字頭部添加邊線
text-decoration:underline;添加底線
text-decoration:line-through;一條線從文字中間橫過
https://ithelp.ithome.com.tw/upload/images/20250923/20178696rKH45dVNna.png
text-decoration-color給text--decoration填色,或是直接在text-decoration打上想要的顏色

        <p style="text-decoration: overline violet;">overline</p>
<p style="text-decoration: underline;text-decoration-color:aqua ;">underline</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696DuTuN0mRgU.png

text-decoration-style:裝飾線的樣式
text-decoration-style:solid實線(默認)
text-decoration-style:double雙實線
text-decoration-style:dashed虛線
text-decoration-style:dootted點線
text-decoration-style:wavy波浪
https://ithelp.ithome.com.tw/upload/images/20250923/20178696rXDHkVF1kL.png
text-decoration-thickness:設定text-decoration的大小,
https://ithelp.ithome.com.tw/upload/images/20250923/20178696RZjqwngqji.png
word-spacing和letter-spacing都是給文字添加間距用的,letter-spacing是給每個英文字母或中文單字都加上空隙,word-spacing是每個單字空隙

        <P style="word-spacing: 10px;">Lorem ipsum dolor sit amet consectetur</P>
        <p style="letter-spacing: 10px;">Lorem ipsum dolor sit amet consectetur</p>

https://ithelp.ithome.com.tw/upload/images/20250923/20178696XRd7LCS9bI.png


上一篇
day8塊元素
系列文
HTML&CSS30天修煉9
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言