把日常最常翻查的屬性整理成一頁,寫樣式時對照即可。
文字屬性
| 屬性 | 作用 | 屬性值 |
| font-family | 定義字型,依序尋找,先找到者生效,皆無則用預設 | 宋體、黑體等 |
| font-style | 字體風格 | normal(標準)、italic(斜體)、oblique(傾斜) |
| font-variant | 英文字母顯示形式 | normal、small-caps(小型大寫) |
| font-weight | 字體粗細 | normal(≈400)、bold、lighter、bolder,或 100–900 |
| font-size | 字體大小 | pt(點)、px(像素)等 |
文本屬性
| 屬性 | 作用 | 屬性值 |
| text-decoration | 文字裝飾 | underline(底線)、overline(頂線)、line-through(刪除線)、none(預設) |
| text-align | 對齊方式 | left、right、center、justify |
顏色屬性
color 定義字色,三種寫法:英文關鍵字、十六進位(如 #ff0000)、RGB 數值(如 rgb(255,0,0),範圍 0–255)。
背景屬性
| 屬性 | 作用 | 屬性值 |
| background-color | 背景顏色 | 同 color 的三種寫法 |
| background-image | 背景圖像 | background-image: url(bg.gif) |
| background-repeat | 背景複製方式 | repeat、repeat-x(水平)、repeat-y(垂直)、no-repeat |
| background-attachment | 背景是否固定 | scroll(隨前景滾動)、fixed(固定不動) |
| background-position | 背景位置 | top、bottom、left、right;或 xxpt xxpt、x% x%、left top(兩個關鍵字間需空格) |
邊界屬性
| 屬性 | 說明 |
| margin-top / -right / -bottom / -left | 四邊邊界,預設值 0,關鍵字 auto,單位可用 pt、px、in、cm |
邊界簡寫規則
DIV { margin: 10cm } → 四邊皆 10cm
DIV { margin: 10cm 3cm } → 上下 10cm,左右 3cm
DIV { margin: 1cm 3cm 5cm 7cm } → 上 1、右 3、下 5、左 7cm