A Web Design Community curated by Chris Coyier

Make All Links Feel Subtly More Button-Like

By: Chris Coyier on 2/1/2010

On this current design of CSS-Tricks, you may have noticed how all links bump themselves down one pixel as you click them. I started noticing this effect on sites of luminaries like Tim Van Damme and Andy Clarke’s sites, so credit where credit is due.

As you might imagine, it’s incredible simple. Let’s take a look.

Because we are wishing to achieve this “bump down” affect on all links and links are inline elements, margin-top won’t work. We don’t want to use padding either, because that would change the size of the box itself which might leading to shifting other elements around it as well which is undesirable. The perfect fit is position: relative, which allows us to bump around elements from their original static positioning.

a:active {
  position: relative;
  top: 1px;
}

On this site, this is a zoom-in look of the one-pixel down shift:


Subtle, but it moves.

Concerns

On this site I use it just like the code above, meaning it affects every link on the site. Some people have said it feels like overkill. Personally I like it and like the consistency, but if you are in the overkill camp (but still like it), use more specific selectors on the anchor element to use in more specific areas of your site.

More importantly, setting a different positioning value for the active state of a link is something you need to be very careful about. If you have any links on your site that are absolutely positioned, having the active state change to relative position will (probably) make them go flying away and render them unclickable. You can fix this on a case-by-case basis by making the active state of those links retain absolute positioning, and even make their top value one higher (or bottom value one lower).

58 Responses

  1. Hitesh says:

    Simple and Effective
    Thanks for sharing

  2. Potentially a bit weird for tabs/images but it’s certainly effective and a nice enhancement for text links. Probably good on the iPhone too

  3. Hitesh says:

    @chris

    you should insert it in snippets area.

  4. Murlu says:

    I love it, it’s very subtle but for some reason it feels just a bit more interactive, the very subtle movement clicks in your head.

    Thanks for sharing this.

  5. bill says:

    Feels gimmicky to me. Oh, and “As you might imagine, it’s incredible simple. ” should be “As you might imagine, it’s incredibly simple. “

    • Eric says:

      Or maybe he meant it in the sense of “wicked simple” instead of “wickedly simple”…?

    • bill says:

      After seeing this in place here for a few days, now I find this annoying and a sign of bad CSS. When I click a link and I see it jump, to me it looks like the designer mucked up something and instead of making links more usable, made then look like a mistake.

      • Oliver says:

        Oh, and “made then” should be “made them” … there is something about stones and glass houses you should maybe reflect on Billy Boy!

        I like it … especially with the underline only on hover

  6. Simon says:

    I hadn’t actually noticed it before, but it is effective.

    I think it’s one of those things that doesn’t jump out at you, but adds to the experience.

    Thanks for the post.

  7. Nikhil says:

    Right post at right time,
    today I was working on sidebar to include this effect and finally got it.
    Thanks Chris…
    :)

  8. Nice little trick that, thanks

  9. Ben says:

    See, this right here is why I keep coming back. It’s all about the details, especially the subtle ones. Thanks!

  10. Great little tip. I’m so adding this to my body text!

  11. Nathan says:

    a great technique, will put it into practice. thanks!

  12. Ginja says:

    That’s the first time I’ve ever used a tip STRAIGHT away. Copy, paste, done job. Tidy little addition to the site I’m working on. Thanks greatly.

  13. Kumo says:

    I use it on buttons links but I don’t like it verry much on text links.

  14. Xitong says:

    This style should be applied carefully. For links with position:absolute property, it will break the link position when clicked

  15. Greg says:

    Love it! I’m trying to imagine a scenario where I’ll have a text link with position:absolute, but I certainly appreciate the heads-up from Xitong.

    The great thing about it is exactly what Chris says in the description: the subtlety. If it shifted on hover-over it might be a bit intrusive. But a quick little shift as it’s clicked? Great!

  16. Chris says:

    Is there a way to “void” the active state if the user:

    -Clicks & Holds the link
    -Rolls off the link (stay on current page)

    I get stuck in the active state which isn’t huge on text links, but for buttons its pretty blatant.

  17. Eamonn says:

    I’ve just implemented this, but kept it to

    p a:active, span a:active

    to stop it from affecting anything major. Worked a treat. Ta!

  18. I guess the days of just changing color are over!

  19. toka793 says:

    Cool stuff, thanks. :)

  20. Steve says:

    cool idea, but i noticed if u click and hold down, but move off the link, it doesnt move back up. maybe set a “top:0″ on the default state?

  21. It’s so subtle, I didn’t even notice it until I really stared, so I don’t think it’s overkill :)

  22. DesignLovr says:

    Great and subtle effect…it might be even better with less than 1 pixel (if that would be possible…)

  23. A very nice subtle effect. I combined it with changing the opacity of the drop shadow on some icons with my links using different rgba() settings to make it look like the icon buttons were being pressed as well.

  24. Tommy says:

    Sweet! I was just implementing something similar on a site I’m building but I was using margin-top. I love it for text links but I’ve also been using it for buttons a lot.

  25. I noticed this the moment you released the new design, and was surprised to see that you set it on all the anchor tags.

    I think it’s fine in a site that is small and doesn’t do anything too crazy, but I would do it more on a single type basis, for example only on buttons, nav links, or maybe ones with class of “ui-nudge” or something.

    Still great to see you do a post on this little detail, I admire your work.

  26. steven says:

    i like this style!

  27. smpn30 says:

    Great job Man… I Love It…

  28. Farid Hadi says:

    That a pretty cool effect. It really improves the UX, even if it’s just a tad bit. Thanks for sharing it with us Chris.

    @Greg McAusland: Thanks for the heads up on the issues it might create if you’re not careful. Maybe there’s a way to tackle that?

  29. Damian Web says:

    I have never thought of doing that, works really well and looks really nice! It really does give a button feel to it. All the little things in attention to detail can really make a site fantastic.

    I will be using this quite a bit I recon! Could you set the positioning so that it drops to an angle? so top:1px right 1px. etc? I guess only one way to find out :p

    Thanks Chris

  30. Cheers Chris, Never thought about this but glad you pointed out the finer details of web design. Like these smaller sort of things.

    Would like to know how you create the fade effect on the leave a comment form. Looks very cool.

    Cheers

    Steven

  31. Mark Inns says:

    This works really well, subtle and just makes the UX a little better.

  32. Jon says:

    Sweet, I’m having that

  33. Mike says:

    Hi Chris,

    Do you have a tutorial on how to create that shadow rollover effect you placed on your content boxes on the right column? I love that!

    Thx!

    Mike

  34. Eliazer says:

    Hi Chris, I always like your stuff…
    oops…. may i dislike this one? :)

  35. Jerry Ross says:

    Noobie question here… How to you get the text to be one color and the underline another?

  36. Jon says:

    I like it. I think it adds that little detail that web designers strive for but also clearly states to the end user that it is indeed a button.

  37. Theo says:

    I had to look at it twice, need new glass prescription.

    I like it, thank you for sharing

  38. REALLY great stuff. A little drawback, though, occurs when you click the link, hold the mouse button pressed then leaves the link. Doing so leaves the link 1px down until you click anywhere else in the page. As I said, a little drawback.

    This situation happens when we are going to click a link then change our mind. Don’t know if there’s a CSS based solution for this.

    Tested in FF 3.6

    Cheers,
    João Cunha

  39. Ian says:

    This is totally simple but utterly effective. As all the best tricks are.

  40. I like it Chris – very subtle, but definitely adds something. I think I’ll try incorporating this into my updoming site redesign

  41. Danny Foo says:

    Personally, I’d miss the link from the start because the blue is too close to the color of the content. Especially when you view the non-underlined links in a paragraph.

    And you know what’ll improve the subtleness, a light grey line underneath the links. Especially if blue you intend to use for links is too close to the content.

    Anyway, this is my personal 2 cents. :)

  42. Michael says:

    has anybody played with the text-shadow declaration in conjunction with a button? I’m giving active links:

    position: relative;
    top: 2px;
    left: 1px;
    color: #22aaff; /* light blue */
    text-shadow: #000000 1px 0px 1px;

    Now, I just have to get the active button to look right.

    • Stephen says:

      I haven’t, but I might look into it. Instead of having text move on a user, it would look more like a button if it does something people normally wouldn’t expect from text links. Using the shadow on a rollover for the text might make it look more smooth.

This comment thread is closed. If you have important information to share, you can always contact me.

* This website may or may not contain any actual CSS or Tricks.