PSD to HTML conversion PSD to HTML conversion PSD2HTML.com with over 300 professionals takes the designs to HTML and beyond

Code Snippet

Home » Code Snippets » CSS » Remove Button Text in IE7

Remove Button Text in IE7

HTML:

<input class="button" type="button" value="Go">

.. or ..

<button class="button">Go</button>

CSS:

input.button { text-indent: -9000px; text-transform: capitalize; }

Negative-indent alone unfortunately doesn't work to remove text from a button element in IE7, but add text-transform: capitalize; and presto!

Subscribe to The Thread

  1. Mark says:

    Cheers for that mate! Been looking around for a solution to remove the submit text in ie7, its been a head scratcher!

    The text-transform is an odd one to use, but I guess that is ie for you! Thanks again, Mark.

    • Alisatir says:

      Wow, Chris strikes again.

      I used line-height: -9999px for this problem before and it worked.

      Bizarrely in IE tester this method is failing me. I hit up google with the search

      “remove text on buttons ie”

      Who was on the first page of the SERP?

      None other :)

      Thanks Chris!

    • XYZ says:

      hello

  2. AndyiBM says:

    …and IE8 too. Good work – thanks!

    • DOM says:

      {font-size: 0px; line-Height: 0px;}
      Does the same thing

    • Anne says:

      On the contrary, {font-size: 0px; line-Height: 0px;} leaves a small black line over the button that is the text at an incredibly small size.

      The solution posted here by Chris Coyier has been the only thing I have found that works for me. Thanks so much, Chris!

  3. Peter says:

    I`m using padding-left for removing the button text. It`s working exactly

  4. jmb says:

    AWESOME! Thanks a bunch!

  5. ds_sts says:

    Fantastic! Thanks so much!

  6. reg3n says:

    you just saved my life :D

  7. Adam Poots says:

    You sir, are a mad genius!

  8. lala says:

    that browser is an asshole.

  9. Cat says:

    Pure brilliance, I’d say – thanks so much!

  10. John says:

    Nice fix… thanks a ton!

  11. Regan Shepherd says:

    Nicely played sir! But what if your browser is 9000px wide. Just kidding!

  12. Colin says:

    I didn’t find this worked for IE7 (well, IE8 in ‘IE7 mode’); The text-transform didn’t bring the buttons back from off screen.

    What did work was NOT using text-indent or text-transform and instead using:
    line-height: 100px;
    font-size: 0px;

    So while the font-size does leave a tiny line of letters on screen in some browsers, that line of offset by the line-height. (Line-height doesn’t seem to work in Firefox, but Firefox seems to respect the font-size of 0. Use a bigger line-height for bigger graphics.)

    • You should never have font-size: 0px; if you can avoid it as some assistive technologies will ignore this text altogether (and thereby not know what your button is for). Also, the tiny line of letters is an unwanted artefact for a lot of developers/designers.

  13. Steve says:

    This just saved me a lot of hassle, thanks!

  14. Adam says:

    Huge help! Thanks!

  15. No f’ing way! Thanks so much for posting this solution – IE is less like programming and more like witchcraft!

  16. Ricardo says:

    letter-spacing:9999em; combined with text-indent also works :)

  17. Ivan Junge says:

    Hah! I don’t know what it is about the text-transform: capitalize; but it worked like a charm. Thanks.

  18. nick says:

    LOL thats just damn weird. nice one.

  19. Rennan Martini says:

    So, I used this properties:

    font-size: 0px;
    line-height: 0px

    Works fine.

    • sonia says:

      Rennan, I had tried this as well and then noticed my bg image had moved by a pixel in Safari and Firefox on Mac. You may want to check this if your pixel precision matters. :)

  20. Mike says:

    I knew I’d find the solution here!.. I’ve been finding stupid ways around this all year.. haha.. Thanks man :)

  21. Karl Wills says:

    Thanks for that Chris, Worked a treat!

  22. Ryan Blake says:

    Thanks for this, it just works, saved me some more ‘parting with hair’

  23. Work’s fine in IE7 & IE8 – thank you Chris!

  24. Alex Dunae says:

    That’s insane but it works. Thanks for sharing.

  25. Gemma says:

    About the most amazing hack ever. You, sir, are a legend.

  26. Albert says:

    i would rather call this one unrelated fail lol… totally random and still works.
    Thank you very much

  27. Kieran says:

    oh wow. how did you ever figure this out. :P

    Thanks

  28. Anna says:

    Wow…really. Fixed my IE7 headache. Thank you.

  29. eric says:

    um, watch out for this.. some browsers will actually create a horizontal scroll bar for the distance you text-indent. Not old browsers, either… the first one that comes to mind is Opera 9.8.

    Always cross-browser test!

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~