CSS - Universal Selector

CSS - Universal Selector

  • In CSS, Instead of selecting elements of a specific type, the universal selector simply matches the name of any element type.
  • To select elements with a specific attribute, write a asterisk (*) character.

Example :

* { 
     color: #FF8000; 

  • The above rule contribute that the content of every element in our document in orange color.

Sample Code :

<!DOCTYPE html>
      * {
       	  color: #FF8000; 
       <b>Wikitechy In Orange</b>
       Welcome to wikitechy

Code Explanation :

   In case, if we want all the elements in the body to be appeared in same font & same color we can create a universal selector by just typing * asterisk.

   In CSS, Color property is used to assign color for the text font.Here, we have given color in hexadecimal code which indicates color orange(#FF8000).

   Font-family property in CSS used to specify a font style. Here, we have applied Arial style for the body elements.

Output :

   The paragraph text “Wikitechy In Orange” will appear in orange color with Arial font style which we had specified in CSS universal selector.

  The heading “Welcome to wikitechy” will also appear in orange color with Arial font style .