早期 HTML 使用表現層屬性/標籤控制樣式(color, face, size, bgcolor, align 等)。現代開發完全由 CSS 接管,但維護舊項目、解析郵件模板、處理富文本編輯器輸出時,需了解映射關係。
| CSS 屬性 | 對應 HTML 屬性/標籤 | 備註 |
|---|---|---|
color | <font color="..."> | 十六進制/顏色名 |
font-family | <font face="..."> | 字體族列表 |
font-size | <font size="1-7"> | HTML size 1-7 對應 px 約 8/10/12/14/18/24/36 |
font-style: italic | <i> / <em> | 語義化首選 <em> |
font-style: oblique | <i> | 斜體傾斜 |
font-weight: bold | <b> / <strong> | 語義化首選 <strong> |
text-decoration: underline | <u> / <ins> | 語義化首選 <ins> |
text-decoration: line-through | <s> / <strike> / <del> | 語義化首選 <del> |
| CSS | HTML 屬性 |
|---|---|
list-style-type: disc | <ul type="disc"> |
list-style-type: circle | <ul type="circle"> |
list-style-type: square | <ul type="square"> |
list-style-type: decimal | <ol type="1"> |
list-style-type: lower-roman | <ol type="i"> |
list-style-type: upper-roman | <ol type="I"> |
list-style-type: lower-alpha | <ol type="a"> |
list-style-type: upper-alpha | <ol type="A"> |
| CSS | HTML 屬性/標籤 |
|---|---|
text-align: left/center/right/justify | <p align="...">, <div align="...">, <table align="..."> |
vertical-align | <td valign="top/middle/bottom"> |
float | <img align="left/right"> |
border | <table border="1">, <img border="1"> |
background-color | <table bgcolor="...">, <td bgcolor="...">, <body bgcolor="..."> |
width/height | <table width="...">, <td width="...">, <img width="..." height="..."> |
cellpadding | <table cellpadding="..."> → td { padding: ... } |
cellspacing | <table cellspacing="..."> → table { border-collapse: separate; border-spacing: ... } |