CSS Universal Selector | CSS Selectors

CSS Universal Selector

The universal selector will select groups of elements and apply a style rule. The symbol for the universal selector is the asterisk (*). For example, to set a default color for all elements within a file, use the following rule:

* {color: blue;}

You can also use the universal selector to select all children of an element. For example, the
following rule sets all elements within a <div> element to a sans-serif typeface:

p * {font-family: Arial;}

The universal selector is always overridden by more specific selectors. The following style rules show a universal selector along with other rules that have more specific selectors. In this example, the <a>  rules override the universal selector.

* {color: purple;}  /* Universal Selector */ 
a {color: red;} /* Specific Selector */


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s