Custom Header in CSS

NOTE: you may use the image linked in the sample CSS below. it was released under the GPL as part of the Disconnected theme. Please DO NOT use my header image.

So you bought the Custom CSS upgrade. but you’ve already got a header image that you like, so you don’t want to change themes to sandbox, since sandbox doesn’t have a custom header. good news! you can still have a clickable header. here’s the trick:

h1 a {
background: url( top center no-repeat;
border:1px solid #FFFFFF;
text-indent: -9000px;

what it does:

h1 a – h1 is the highest level header. it’s used for the title of your page (blog, whatever). it’s only allowed to occur once. ‘a’ is the link. (when you see elements listed like that, with spaces inbetween, later elements occur inside the first element).

display:block; – links, by default, are inline elements (they don’t force a new paragraph). we need this element to have height and width properties, so we’ll need it to force elements to stack under it (block), rather than wrapping around it (inline)

background: url() – this is the picture we’re going to use. since it’s going to act as a link, you’ll want it to have the name of your blog (in some fancy font), or something that signifies that it should be clicked (also known as affordance).

height:147px; width:660px; – this is the height and width of the image. this is going to determine how big our clickable area is as well, so if you center the image, but you want the entire top of the page to be clickable, you might want to use width:100%; instead.

text-indent: -9000px; – this is where we get tricky. if we leave out this line, you’ll have a clickable header, but it will have the text of the link on top of it. that defeats the point, most of the time. so we’re going to push the text off the page. 9000 pixels to the left, out of sight, out of mind.

and we’re done!. you’ll still get all the search engine benefits of semantic markup on the title, but you can make your header look as pretty as you want it to.

Bookmark This:

add to :: add to ma.gnolia :: Stumble It! :: seed the vine :: TailRank


26 thoughts on “Custom Header in CSS

  1. timethief

    OMG I think I might even understand sort of and for a non-coding computer dummy that’s a huge accomplishment. So I’ll be bookmarking this page for that day when the cyber light shines and I can actually consider construct (breaking/destroyingre-building) a theme. P.S. Perhpas you should make a post in the wordpress css customization forum with a link back to this useful information.:D

  2. Pingback: » Try Custom CSS

  3. adam Post author

    @ TT – thanks!
    there’s sort of a general etiquette that posting a link to your own article is spam-ish.

    getting the official blog to link you seems ok to me, though 😉

  4. Sorry about using your header, coz it’s simply convenient to copy & paste both up & down. Pls continue to share your ideas. Thanks. ^^

  5. adam Post author

    well, thanks for fixing it 🙂
    i’m glad to see you’re learning by doing (it’s the same way i learned). i can’t wait to see your blog finished.

  6. I’m almost new to html language, now reading page by page at I guess it may take weeks for a satisfactory design. Anyway, it’s really funny to customize my own page.

  7. johan

    Thanx a lot. this technique is what i was looking for since 2 days 😀

  8. Alik

    Thanks for this! I was having a hard time figuring out how somebody else did it. Nice and clear. merci beaucoup.

  9. adam Post author

    i’m not sure why your layout is being so difficult. the only way i could get it to work on yours was by using #blog-title a { width: 100%; }. i don’t know what you’ve got planned, but if that works for you, i’d say use it, even if it’s an ugly hack.

  10. Matthew

    Thanks for posting this information! I’m sure reading will answer my question, but I am curious how you were able to make the style sheets both in front of and behind your header image! That’s just amazing. If you have any direct information, please feel free to email me. Thanks =)

    (for non site owner, just post here)

  11. adam Post author

    ow you were able to make the style sheets both in front of and behind your header image!

    do you mean the way the logo images changes when you hover on it, or the transparent appearance of the header itself?

    you can see the images that make up the header here, it’s basically flat images that look transparent but aren’t. i didn’t design this theme, btw, check out the links at the bottom of the page.

    the changing logo is accomplished by simply adding

    h1 a:hover { background-position: -200px 0 }

    that way the whole 400px wide image loads right away, and just gets moved over to where the highlighted portion of the image is.

  12. Matthew

    Thanks for the quick reply! Just after I posted this (Thats always how it goes) I found the link to the theme, and downloaded the .zip file, and upon extracting it, I noticed that in fact they were, as you said, simply flat images that matched the background image.

    It’s just a very neat theme, but yes, my specific question was how were you able to make parts of your CSS transparent while other parts were not transparent.. but as I can see, and as you pointed out, it’s simply flat images. I was unable to right-click on them and view image, so thats what had me confused.

    In any case, thanks again for the quick response! I’m obviously a little old-school in my HTML, and am in desperate need of improvement =)

    Great site!

  13. adam Post author

    you can achieve a similar effect with transparent PNG’s, although you can’t make things blurry. unfortunately, they don’t work in IE 6. you can check out vistered little for an example of that.

  14. Andrew Kelsall, Sqwi

    That’s a great turial, although I’m just wonding about the -9000 thing. If I use this method to create a header, will I be penalized by Google and other search engines because the header is off the page. Will it be seen as an atemt to spam by the robots they utilize??

    Any help would be great…

  15. adam Post author

    AFAIK, no, you won’t be penalized. using display: none; penalizes you, but text-indent should be ok.

    i doubt that would change, since a long string of text would start to appear. this only works for short link texts.

  16. jabbott


    I’m trying to adapt your code, and it’s working great in Internet Explorer, but the banner image is not displaying for me in Mozilla Firefox 1.5 for the PC.

    Here’s the coding snippet from my custom stylesheet:

    h1 a {
    background:#2F757F url(‘’) top center no-repeat;

    Linking directly to the URL in Firefox displays fine, so I know it’s not the image or the URL. Any suggestions would be most appreciated!

  17. adam Post author

    if you uploaded the image via the custom header page, it won’t work. it’s a bug in you can rename the image, and upload in the Write > Post page of your dashboard. the new image should work just fine.

  18. jabbott

    Thanks for your reply and suggestion. I removed all the banner graphics previously uploaded, then used the Write > Post page to upload again. However, I didn’t try renaming…will try that now. Here’s my question: if the post is a draft (not published), will that matter? If so, how do I publish without the post being seen in the blog.

  19. jabbott

    Answered my own question — the graphic is working now. It turned out there was a flaw in the graphics file itself. Once re-opened in Photoshop and resaved, the error disappeared and the banner is now displaying in Mozilla. This one was weird, because I could display the image by itself in the browser, but the truncation or error in the graphic file only caused a problem once the file was inserted in a page in Mozilla. I’ve never seen that before! When in doubt, go back to square one. Thanks again for your coding suggestion!

Comments are closed.