Universal selector in CSS

The universal selector * allows you to select all elements.

Syntax

css* {
  
}

Example

Let's select all the elements and color them red:

css* {
  color: red;
}

Example

Let's select all the elements inside the div tag and color them red:

cssdiv * {
  color: red;
}

Example

Let's select all the elements directly inside the div tag and color them red:

cssdiv > * {
  color: red;
}

Example

Let's select all elements that are inside the span tag, which in turn is inside any tag that in turn is inside the div tag:

cssdiv * span {
  color: red;
}

See also

  • the border-width property
    that specifies a border width
  • the border-style property
    that specifies a border type
  • the border property
    that is a shorthand property for a border