text-decoration: none | underline | overline | line-through | blink | inherit
/* 顏色由 color 屬性決定 */
text-decoration-line: underline overline; /* 多重線條 */
text-decoration-color: #f06d06; /* 線條顏色獨立於文字色 */
text-decoration-style: solid | double | dotted | dashed | wavy; /* 線條樣式 */
text-decoration-skip: ink | spaces | edges | objects; /* 避開下沉字形、空格、邊緣、行內元素 */
a { text-decoration: underline overline; }
a { text-decoration-color: #f06d06; }
瀏覽器渲染差異:Gecko (Firefox) 下劃線在字形下方;WebKit/Blink (Chrome/Safari) 在字形上方。
a { text-decoration-style: wavy; }
border-bottom 無法實現波浪/虛線等豐富樣式。
避開下沉字形 (g, y, p 等) 的下劃線:
a { text-decoration-skip: ink; }
配合半透明色降低對比度:
a {
text-decoration-color: rgba(0,0,0,.4);
text-decoration-skip: ink;
}
spaces:跳過空白字符edges:首尾留白objects:跳過行內替換元素 (img, input 等)
Safari/iOS 似乎默認啟用部分 skip 行為。
text-decoration-color/style/skip) 僅現代瀏覽器支援border-bottom + padding-bottom 模擬下劃線,控制力更強@supports (text-decoration-style: wavy) {
a { text-decoration: underline; text-decoration-style: wavy; }
}