CSS selectors

Derek Bridge

Department of Computer Science,
University College Cork

CSS selectors

Aims:

The evils of mixing structural and presentational markup

Cascading Style Sheets (CSS)

h1 {color: red; background-color: blue;}

Attaching a stylesheet to an (X)HTML document

Advantages of CSS

Simple selectors

Id selectors

Class selectors

Descendant selectors

Class Exercise

Dynamic pseudo-class selectors for hyperlinks

Class exercise: smallads.html

  1. [Tree structure for smallads.html.] Write a rule to select Zach's menu
  2. Write a rule to select "Zach's"
  3. It might be better if this document used div, span, id and class. Where and why?