Universal Selectors

As you have seen in the previous tutorials there are lots of different ways that we can specify combinations of tags when we are defining stylesheets. There may be times where you have worked out exactly what combination you want except that one tag in the middle of the definition can be anything. In this situation we can use the universal selector as a placeholder in our definition. The universal selector is the asterisk.

For example if we want to test for italics directly nested within another tag that is directly nested within a paragraph we can use:

p>*>i {color:red;}

The universal selector stylesheet definition can also be used to create Internet Explorer specific entries because unlike other browsers that consider html to be the top level tag within your document, IE allows you to nest it within the universal selector. For example the following will assign a stylesheet that applies in all browsers on the first line and override it with specific differences for IE on the second.

p {color:red;}
* html p {color:blue;}


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow