CSS Tutorial 5

Prepared by: Anthony Larrain


CSS Selectors

Class Selectors

Example 1

Suppose you wanted most of the body text blue and some portions red.

body{ color:blue; } .colorchange{ color:red; }

Then in the HTML document that uses these styles use the class attribute to call in the style.

<p>This text would appear blue</p> <p class="colorchange">This text would appear red</p> <h1 class="colorchange">This text would appear red</h1>

Id Selectors

body{ color:blue; } #colorchange{ color:red; }
<p>This text would appear blue</p> <h1 id="colorchange">This text would appear red</h1>

Grouped Selectors

Suppose you wanted all headings h1 h2 h3 .. to be green

h1,h2,h3,h4,h5,h6 { color:green; }

Contextual Selectors

#navigation a { color:green; }
dt a { text-decoration:none; font-size:1.1em; color:hotpink; }

@Anthony Larrain 2005 - 2006

Send Questions or Comments to hci201@yahoo.com