CSS Universal Selector

What is CSS Universal Selector?

CSS Universal Selector match all element type. It's work like global to select all element.
CSS Universal Selector identify by asterisk (*).
CSS Universal selector use when you want to select specific type element to apply CSS style.

Syntax

This syntax apply to select every element in a document.

* {
  property: value;
  property: value;
  ...
}

Example

Select all element to apply font size 24 pixel.

<!DOCTYPE html>
<html>
<head>
  <title>CSS * Selector</title>
  <style>
    * {
       font-size:24px;
    }
  </style>
</head>
<body>
  <p>This is paragraph text</p>

  <h1>This is h1 heading text</h1>

  <h4>This is h4 heading text</h4>
</body>
</html>

Run it...   »

Example

In this example selector *.demo and .demo both are equivalent,

.demo {
  font-size:24px;
}

Run it...   »

*.demo {
  font-size:24px;
}

Run it...   »

Same as *#demo and #demo both are equivalent.

Example

Select all element whose have child of an <ul> element.

ul * {
  background-color:#FF0000;
}

Run it...   »

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 1+
  • Internet Explorer 8+
  • Opera 9.2+
  • Safari 1.3+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.