22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Pseudo Classes<br />

Chapter 12: Top 20 <strong>CSS</strong> Properties<br />

Pseudo classes in <strong>CSS</strong> may seem a little strange at first: They take some getting<br />

used to because they modify (X)<strong>HTML</strong> elements. That explains why Table<br />

12-8 starts each pseudo class name with a colon (it acts as a delimiter with<br />

the element it modifies, and it signals the presence of a <strong>CSS</strong> pseudo class).<br />

Generally, pseudo classes serve to make content on Web pages more dynamic<br />

and interactive, as you’ll discover when you get comfortable with them.<br />

Table 12-8 <strong>CSS</strong> Pseudo Classes<br />

Pseudo Class Description<br />

:active Adds a style to an activated element<br />

:after Adds content following an element<br />

:before Adds content preceding an element<br />

:first-child Adds a style to first child element inside another element<br />

:first-letter Adds a style to first character in a text sequence<br />

:first-line Adds a style to first line in a text sequence<br />

:focus Adds a style to element with keyboard input focus<br />

:hover Adds a style to element as you mouse over it<br />

:lang Adds a style to any element with a specific language<br />

attribute<br />

:link Adds a style to unvisited link<br />

:visited Adds a style to visited link<br />

By far, the most widely used pseudo classes apply to (X)<strong>HTML</strong> links. In the<br />

example in the next section, we combine :hover, :link, and :visited to<br />

show how this works (and looks).<br />

:hover, :link, and :visited<br />

The pseudo classes :hover, :link, and :visited all apply to hyperlinks.<br />

✓ :hover comes into play when the mouse cursor hovers over a hyperlink.<br />

✓ :link applies style to a hyperlink that has not yet been visited.<br />

✓ :visited applies style to a hyperlink that has been visited.<br />

207

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!