概述
CSS元素选择器(也称为类型选择器)通过node节点名称匹配元素. 因此,在单独使用时,寻找特定类型的元素时,元素选择器都会匹配该文档中所有此类型的元素.
语法
元素 {样式声明 }
示例
CSS
span {
background-color: DodgerBlue;
color: #ffffff;
}
HTML
<span>这里是由 span 包裹的一些文字.</span>
<p>这里是由 p 包裹的一些文字.</p>
效果
这里是由 span 包裹的一些文字.
这里是由 p 包裹的一些文字.
规范
规范 | 状态 | 备注 |
---|---|---|
CSS Selectors Level 3 | Recommendation | No change |
CSS 2.1 | Recommendation | |
CSS 1 | Recommendation |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | ? | ? | ? | ? | ? |