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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Type selector (elementName)Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Namespaces (ns|elementName)Chrome Full support YesEdge Full support 12Firefox Full support 1IE Full support 9Opera Full support 8Safari Full support 1.3WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

文件標籤與貢獻者

此頁面的貢獻者: a1178961372, YvonneYu
最近更新: a1178961372,