Skip to content
Related Articles

Related Articles

Improve Article
CSS | * Selector
  • Last Updated : 03 Jan, 2019

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

Syntax:

* {
    // CSS property
} 

Example 1:




<!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) Selctor</h2
        <div
            <p>GFG</p
            <p>Geeks</p
        </div
        <p>It is a computer science portal for geeks.</p>
    </body
</html>                                      

Output:

Example 2:




<!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



My Personal Notes arrow_drop_up
Recommended Articles
Page :