CSS Universal Selector

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The CSS universal selector, denoted by an asterisk (*), is used to select all elements on the HTML page. It is the most general selector, and it can be used to apply styles to any element, regardless of its type or location.

The universal selector can be used alone, or it can be combined with other selectors to create more specific rules. For example, the following rule will apply the specified styles to all <h1> elements on the page:

h1 {
  color: red;
  font-size: 2em;
}

The following rule will apply the specified styles to all elements inside the element with the id my-container:

#my-container * {
  padding: 10px;
  margin: 10px;
}

It is important to note that the universal selector is very powerful, and it should be used with caution. If you are not careful, you could accidentally override more specific CSS rules.

Syntax

* {
    css declarations;
}

Example

* {
   color: #3366ff;
   font-size: 1.1em;
   background: #ffff99;
}

In the above example, the color, font-size and background styles will be applied to all elements on a webpage.

Give it a Try

Click the button below to experiment with this selector.

Give it a Try!

Browser Support

The following table will show you the current browser support for the CSS universal selector.

Desktop
Edge Chrome Firefox Opera Safari
YesYesYesYesYes
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
YesYesYesYesYesYes