選擇器 { 屬性: 值; }
font-family: "sans serif"p { text-align:center; color:red; }h1, h2, h3, h4, h5, h6 { color: green; }
p, table { font-size: 9pt; }
等價於分開撰寫,減少重複。
.right { text-align: right; }
.center { text-align: center; }
/* 省略標籤名,可套用於任意元素 */
.center { text-align: center; }
HTML:<p class="right">...</p>
#intro { font-size:110%; font-weight:bold; color:#00f; }
p#intro { ... } /* 僅針對 p#intro */
ID 唯一,限定性高,僅特殊情況使用。
table a { font-size: 12px; } /* 僅影響表格內的連結 */
!important 提升/* 定義段落樣式 */
p {
text-align: center; /* 文字置中 */
color: black;
font-family: arial;
}