選擇器 { 屬性: 值; 屬性2: 值2; }
color、font-size)。| 類型 | 語法 | 範例 |
|---|---|---|
| 標籤選擇器 | tag | p { color: black; } |
| 類別選擇器 | .class | .highlight { background: yellow; } |
| ID 選擇器 | #id | #header { height: 60px; } |
| 屬性選擇器 | [attr=value] | input[type="text"] { border: 1px solid #ccc; } |
| 偽類 | :hover | a:hover { text-decoration: underline; } |
| 偽元素 | ::before | p::first-line { font-weight: bold; } |
font-family: "Microsoft JhengHei", sans-serif;color: red;、margin: 10px;p {
text-align: center;
color: red;
font-size: 16px;
line-height: 1.5;
}
{} 或分號 ;。.calss)。font-color → 應為 color)。width: 100 → 應為 100px)。善用瀏覽器開發者工具「Styles」面板即時編輯驗證。