15 responses to “Valid XHTML Clickable Header Images”

  1. Chris Houston

    Hi Justin, this was exactly what I was originally wrapping a DIV with a LINK. Now it’s all fixed and our site is valid XHTML :)

    Thanks for posting!

    Chris

  2. Justin

    No problem Chris. I’m glad somebody finally used this tutorial. I expect the masses are still wrapping the <a> element around <h1> or <div>.

  3. Tony

    Awesome Justin!!

    Thank you very much – makes it nice and clean! Exactly what I’ve been looking for!

    Tony

  4. Brian

    You are a legend , well done. I’ve been searching online for hours looking for a valid markup example of this and your solution is perfect. Works perfectly. Much appreciated for this post

    excellent work

  5. Jocke

    Nice!

    But you can’t use “display: none” for the SPAN. Anything set to display: none or hidden won’t be used by screenreaders (like JAWS 9) making it useless for blind people.

    Love to see a valid solution for that one.

    /J

  6. Arne Brasseur

    How about adding
    text-indent: -9999px;?

    This makes the text disappear, but it will still be read by screen readers, and you don’t need the extra <span>

    It works in Firefox, I still have to try the other browsers.

  7. Eric Schmitt

    @ Arne Brasseur:

    How about adding
    text-indent: -9999px;?

    This makes the text disappear, but it will still be read by screen readers, and you don’t need the extra

    Andy Budd covers this in his book, CSS Mastery.. pg 65. While this method works well with screen readers, it does not work when images are turned off but CSS is turned on… probably only applicable for people with slow connections, or who use their cell phones as modems. For this reason, Andy cautioned against using this method. Instead he recommended the Gilder/Levin method as the most robust method currently available. This method adds an empty, non-semantic span element before the text. It uses relative position for the parent element and absolute positioning for the span element to “cover up” the text. Anyhow, just thought I’d chime in since I’m playing with this as well..

  8. Edward Kobus

    Hey Justin,

    I want to use pictures as links. To show the user the picture is indeed a link this picture has to change when the mouse moves over. I do know how to do this in plain html, in a wordpress header however it won’t work; no picture is shown except for this tiny 1px high thingy that does work.

    code:

    Any idea?

    Thanx!

  9. Michelle E

    Thanks so much for taking the time to post this tutorial. I learned html back when CSS was still thought of as risky and not supported by browsers, so re-learning now is really amazing! So many great new tricks and techniques. This one worked great.

  10. Dimitry

    Thanks! Save me a lot of time. That’s what I was looking for.

  11. Northman

    Justin,

    I’m just starting to convert my sites to CSS – and a clickable header was what I was looking for – MANY thanks!

    N

  12. BLB

    Thank you so much for this tutorial! Works like a charm.

  13. Kate

    I have been using a variation of this code for my own header for awhile now, but I have not been able to figure out how to do a second row of clickable header image/links. Any advice?

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.

WordPress-o-Sphere

  • WordPress 2.8 – "Baker"
    WordPress 2.8 adds hundreds of bug fixes, adds cool functions for themes, boasts a new widget API, and makes custom taxonomies easy for end users.
  • WeRockWP
    WeRockWP recognizes and showcases the individuals who contribute much to the WordPress community. These individuals are called WordPress Rockstars.
  • wpazo
    The all-signal, no-noise, source for the best WordPress stuff.
  • BuddyPress 1.0 has arrived
    The long-awaited BuddyPress (a set of plugins that turns a WordPress MU install into a social network) has been officially released.
  • BuddyPress for WordPress (not MU) coming
    It looks like BuddyPress will also be released for normal WordPress installs (not just WPMU).