CSS Universal Selector



Universal Selector :

We have seen “ID Selector” and “Class Selector” in our previous chapters now we are going to see the “Universal Selector”.

  1. The universal selector is an represented by asterisk.
  2. When used , the universal selector tells the CSS interpreter to apply the CSS rule to all elements in the document.
  3. *Precaution : Do not use Universal Selector unless it is mandatory.

Example : Universal Selector

* {
    font-family: Arial, Helvetica,sans-serif;
}

Complete Example : Universal Selector

<html>
    <head>
        <style type="text/css">
            * {
                font-family: Arial, Helvetica, sans-serif;
            }
        </style>
    </head>
    <body>
         <h1>This is H1 Type Heading !!</h1>
         <h2>This is H2 Type Heading !!</h2>
         <h3>This is H3 Type Heading !!</h3>
    </body>
</html>

Explanation :

    1. Universal rule is applied to each and every elements contained in the document.
    2. Universal selector rule is also applies to form input fields and tables of data.
    3. All elements would have following property applied –
font-family: Arial, Helvetica, sans-serif