← Back to home

CSS Tip: Three-State Buttons

August 11, 2008

Let’s say you have a text button that highlights when you hovered. You can add a third state, when clicked, by specifying a:active the same way you use a:hover. No javascript needed.

In your html:

<a href="#" class="button">
  Some Text

In your css:

a.button:link, a.button:visited, a.button:hover {
  padding: 15px;
  text-decoration: none;
  color: #666;
  border-bottom: 1px solid #CCC;
  font-size: 12px;
a.button:hover {
  background-color: #F9F9F9;
a.button:active {
  background-color: #FFF;
  color: #333;


← Back to home