Chapter 5. Styling Links

The humble anchor link is the foundation of the World Wide Web. It is the mechanism that allows web pages to interconnect and people to explore and navigate. The default styling for anchor links is fairly uninspiring, but with a little sprinkling of CSS you can do some amazing things.

In this chapter you will learn about

  • Ordering your link selectors based on the cascade

  • Creating stylized link underlines

  • Styling external links using attribute selectors

  • Making links behave like buttons

  • Creating visited-link styles

  • Creating pure CSS tooltips

Simple link styling

The easiest way to style a link is to use the anchor type selector. For instance, this rule will make all anchors red:

a {color: red;}

However, anchors can act as internal references ...

Get CSS Mastery: Advanced Web Standards Solutions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.