在线文档教程
CSS

类型选择器 | Type selectors

Type selectors

CSS 类型选择器按节点名称匹配元素。换句话说,它选择文档中给定类型的所有元素。

/* All <a> elements. */ a { color: purple; }

语法

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>

结果

规范

SpecificationStatusComment
Selectors Level 4The definition of 'Type (tag name) selector' in that specification.Working DraftNo changes
Selectors Level 3The definition of 'type selectors' in that specification.RecommendationNo changes
CSS Level 2 (Revision 1)The definition of 'type selectors' in that specification.Recommendation
CSS Level 1The definition of 'type selectors' in that specification.RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support??(Yes)????