Open In App

CSS * Selector

Last Updated : 10 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The * selector in CSS is used to select all the elements in an HTML document. It also selects all elements which are inside under another element. It is also called the universal selector.

Syntax: 

* {
    // CSS property
} 

Example 1: This example shows the use of the CSS universal selector.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>* Selector</title>
 
    <!-- CSS property of * selector -->
    <style>
        * {
            color: green;
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>*(Universal) Selector</h2>
    <div>
        <p>GFG</p>
 
        <p>Geeks</p>
    </div>
 
    <p>It is a computer science portal for geeks.</p>
</body>
</html>


Output: 

Example 2: This example shows the use of the CSS universal selector.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>* selector</title>
 
    <!-- CSS property for * selector -->
    <style>
        * {
            background: green;
            font-weight: bold;
            margin-left: 70px;
            color: white;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>*(Universal) Selector</h2>
 
    <ul>
        <li>Data Structure</li>
        <li>Computer Network</li>
        <li>Operating System</li>
    </ul>
 
    <ol>
        <li>Java</li>
        <li>Ruby</li>
        <li>Pascal</li>
    </ol>
</body>
</html>


Output: 

Supported Browsers: The browser supported by *(universal) selector are listed below: 

  • Apple Safari 3.1
  • Google Chrome 4.0
  • Firefox 3.0
  • Opera 9.6
  • Internet Explorer 7.0


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads