元素選擇器


CSS 元素選擇器 (也稱 型態選擇器)依照 Node 節點名稱選取匹配的 Element 元素。換句話說,此選擇器選取在 Document 文件內所有指定該型態的元素。
 
/* 全部的 <a> 元素。*/
a {
  color: red;
}

語法

element { style properties }

範例

CSS

span {
  background-color: skyblue;
}

HTML

<span>Here's a span with some text.</span>
<p>Here's a p with some text.</p>
<span>Here's a span with more text.</span>

Result

規範

Specification Status Comment
Selectors Level 4
The definition of 'Type (tag name) selector' in that specification.
Working Draft No changes
Selectors Level 3
The definition of 'type selectors' in that specification.
Recommendation No changes
CSS Level 2 (Revision 1)
The definition of 'type selectors' in that specification.
Recommendation  
CSS Level 1
The definition of 'type selectors' in that specification.
Recommendation Initial definition

Browser compatibility

BCD tables only load in the browser