Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

元素选择器

概述

CSS元素选择器(也称为类型选择器)通过node节点名称匹配元素. 因此,在单独使用时,寻找特定类型的元素时,元素选择器都会匹配该文档中所有此类型的元素.

语法

元素 {样式声明 }

示例

CSS

span {
  background-color: DodgerBlue;
  color: #ffffff;
}

HTML

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

效果

Here's a span with some text.
Here's a p with some text.

规范

Specification Status Comment
CSS Selectors Level 3 Recommendation No change
CSS 2.1 Recommendation  
CSS 1 Recommendation  

浏览器兼容性

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 ? ? ? ? ? ?

See also

文档标签和贡献者

标签: 
 此页面的贡献者: fscholz, teoli, alimon
 最后编辑者: fscholz,