CSS element Selector

Definition and Usage

CSS element Selectors are used to select all elements with specified element names.

Used in @namespace When, this selector can be namespace qualified.

  • ns|p - Select <p> elements in the namespace ns
  • *|p - Select all <p> elements
  • |p - Select all <p> elements that have not declared any namespace

Example

Select and set the style for all <h1> elements, and select and set the style for all <p> elements:

h1 {
  border: 2px solid green;
  background-color: beige;
}
p {
  background-color: yellow;
}

Try It Yourself

CSS Syntax

element {
  css declarations;
}

Syntax of CSS with Namespaces

namespace|element {
  css declarations;
}

Technical Details

Version: CSS1

Browser Support

Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持