Howto: Replace your h1 text with an image

The purpose of this howto is to replace your <h1> text with an image resulting something like this

h1 Replaced

Why?

Because you can have a simple anchor text like <h1>very good keyword</h1> seen by search engine and in the same time you get an image saying another cool tagline.

And because images is prettier than plain text, unless you’re Jon Tangerine, that is.

How?

First you have to create an image that you’re going to use to replace the <h1> tag and note the dimension (that is the height and width).

The html is pretty simple really:

<h1>Something here</h1>

And the CSS goes like this:

h1 {
background: url(images/url_ke_gambar.jpg);
height: tinggi_gambar_disini px;
text-indent: -999em;
width: lebar_gambar_disini px
}

Piece of cake, eh? Now you’d want to take this further by replacing other html tags with images. You can apply the same CSS style to any html tag like <label> or <h4 class="title">. But do remember tho, if you want to use it on a link, you will need to define display: block to the link, like this

h1 a {
background: url(images/url_ke_gambar.jpg);
display: block;
height: tinggi_gambar_disini px;
text-indent: -999em;
width: lebar_gambar_disini
}

Well, so much for a tutorial eh? I’m not good at this but I’m trying :D

Note: the tinggi_gambar_disini px thing should look like 190px, I write the space in between for the sake of nice reading.

23 Responses to “Howto: Replace your h1 text with an image”

  1. Deny Sri Supriyono says:

    nice one, mate! :)

  2. Hedi says:

    oooo gitu tho, ini lebih cespleng penjelasan ketimbang di web2 tutor :D

  3. Jauhari says:

    Kok kemaren ndak jadi KONTAK? jadi ndak ke Malangnya kang?

  4. daustralala says:

    tanya pak, itu “tinggi_gambar_disini px”, px-nya bukannya mestinya dempet ya dengan “disini”?

  5. anima says:

    @daustralala yak begitulah :D
    *post updated*

  6. ikecek says:

    ekhm…
    properti text-indent itu maksudnya apa yah?

    *ngetes mode on

  7. lita says:

    kok kayaknya nuansa warna blognya suram banget ya?
    lebih suka yang dulu deh

  8. mbakDos says:

    waahh… udah lama banget gak mainan yang begituan! dulu waktu masih numpang dan ngutak-ngatik rumah di blogspot sih rajin, nah sekarang…?!

  9. Riri Audiya says:

    setau saya, lebih baik pk teks untuk H1. biar SE bisa baca,.

  10. dani says:

    buy 1 get 2 :)
    does it possible to make “buy 1 get 4″?
    in the next HTML 5, they’ll have “audio” and “video”.. :D cmiiw yaa..

  11. Silverlines says:

    HAPPY BIRTHDAY!!
    May all the wishes come true and your life’s full with happiness.

    Party hard?

  12. amazu says:

    I need more like this,
    I’m usually do the css work by self learning, not with the books or formal tutor. As long as my design looks great, i don’t give a damn with css rules. Now I’m realize it that I was wrong (hope not like “ketika kamu menyadarinya semua sudah terlambat”)

  13. anima says:

    @ikecek: buat meng-indent brur, nah indent to ape kaden artine
    @lita: you think so? then the redesign was a success ;)
    @Riri Audiya: ini dibaca SE sebagai teks biasa kok jeung (eh, SE disini maksudnya Search Engine, bukannya SonyEricsson kan?
    @dani: it is very possible sir :D
    @Silverlines: thankyou! yup, kinda, still on hangover :D
    @amazu: I will do more of these kinds of article dude, dan ini belum terlambat sebelum kamu menyadarinya demikian

    And this, ladies and gentlemen, is the longest comment I’ve ever made on this blog.

  14. Pay Joe says:

    Ane coba tuh boss tips nya.. tp kok cmn nge set tex-indent nya doank jd 999em ? en jadi nyekroll ke samping tuch…

  15. Kana says:

    kalo gw masih luang kaya dulu dah gw cobain trik dari lo nih! sayang gw lagi hectic beratttt!!!! ><;;;

  16. anima says:

    @Pay Joe: Maybe you forgot to declare the width? Post some codes so we can see dude :D
    @Kana: Haha, semua orang lagi miskin waktu luang yah sekarang. Sama kok jeung

  17. Pay Joe says:

    here’s the code boss..

    h1 {
    background: url(ohh.gif);
    text-indent: 999em;
    width: 240px;
    height: 320px;
    }

  18. ikecek says:

    #Pay Joe : text-indent nya coba di kasi - (minus) semoga aja bisa tuh.
    misalnya: text-indent: -9000px;

  19. anima says:

    @ Pay Joe & @ ikecek: MY BAD :D
    sorry forgot the minus, seharusnya text-indent: -999em tuh..

  20. bodhi says:

    saya merasa kehilangan dua titik koma. atau memang begitu saja bisa?

  21. anima says:

    @bodhi titik koma di selector terakhir kah? kalo itu sptnya bisa diomit, or did I miss something else? :|

  22. Pay Joe says:

    Alright… very good Mr. Prima… i’m very proud of you…

  23. anima says:

    @Pay Joe: Oh it’s you! :))

Leave a Reply

Commenting guidelines

  • HTML enabled, allowed tags are <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .
  • I'm not deleting any comments unless you spam me, write what you want.
  • Typos happen, resubmit if you did one, I will delete the first.
  • You might want to get a gravatar to look cool.