A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$subtype

Filename: models/page_setup.php

Line Number: 15

saila.com: How do I style links?

Jump to Content

Welcome to the beta of the new saila.com. Send in your bugs.

How do I style links?

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: continue

Filename: views/article.php

Line Number: 17

A linked anchor (a) element has a series of pseudo-classes that can be applied to it (:link and :visited) in addition to :active and :hover. For CSS-1 style sheets, this is the best way to style links:

a:link { background: inherit; color: #00f; }
a:visited { background: inherit; color: #c09; }
a:hover { background: #ff0; color: inherit; }
a:active { background: inherit; color: #f00; }

But CSS-2 allows :active and :hover to be applied to any element, so the above can be written as:

a:link { background: inherit; color: #00f; }
a:visited { background: inherit; color: #c09; }
a:link:hover, a:visited:hover { background: #ff0; color: inherit; }
a:link:active, a:visited:active { background: inherit; color: #f00; }

(the above works in most fifth-generation browsers).

By attaching :active and :hover to :link and :visited, you can:

For more on this read David Baron’s in-depth explanation.

Category: Web Design

Topic: CSS


Jump to navigation