IE Hack - Hide Text on your Submit Buttons
Recently, I designed a website and I decided to do a unique style on the search field. I added a background image to the input field and then a background image to the submit button. Everything looked great until I viewed it in Internet Destroyer (Internet Explorer). That’s when the sky fell on my head…as usual.
The Issue:
I was not able to hide the text from the button, letting the underlying image to show it’s text. Normally my preferred image replacement technique is to have text in the background image and then use a negative text-indent at a high number like this:
background-image: url('my-picture-with-text.jpg');
text-indent: -9999px;
This works fine with submit buttons on most browsers, except IE.
The fix:
Add 2 extra lines to your css file:
color: transparent; text-transform: capitalize;
For some reason the text indent dosn’t work by itself in IE, so after adding these 2 lines it works. It is a hack within a hack though, the color:transparent property should work by itself, but it doesn’t. For some odd reason setting the text-transform to anything (in this case I chose capitalize because I don’t use it very often) makes it magicly work. Anyhow if anyone finds this useful please leave a comment below.


16 Responses to “ IE Hack - Hide Text on your Submit Buttons ”
February 13th, 2009 at 1:06 pm
wow! Just what I needed! Thanks.
February 25th, 2009 at 10:19 am
Nice find, this also seems to work:
==================
line-height: 999px; /* Set it higher than your image height */
overflow: hidden; /* Hide the text */
font-size: 0; /* FF2 doesn’t like the above */
==================
But your solution is neater
March 4th, 2009 at 7:24 am
Thanks for this, really useful.
March 5th, 2009 at 12:18 pm
Cool, thanks for the alternate method Chris. I am going to give it a whirl sometime soon.
May 7th, 2009 at 11:55 am
Thank you very much! I found your website through the mans best friend (google) and it did just the trick!
May 26th, 2009 at 2:15 am
[...] Source Categories: Web Development Comments (0) Trackbacks (0) Leave a comment Trackback [...]
June 2nd, 2009 at 10:43 pm
When I tried your method the submit button disappeared entirely on IE7. Has anyone else had this problem?
July 24th, 2009 at 8:37 am
I had that problem on a project and it has something to do with a property set (I think position relative) somewhere before the button in the mark up. When I had that problem I used Chris Mahon’s method above and it fixed it.
Chris Mahon Says:
February 25th, 2009 at 10:19 am edit
Nice find, this also seems to work:
==================
line-height: 999px; /* Set it higher than your image height */
overflow: hidden; /* Hide the text */
font-size: 0; /* FF2 doesn’t like the above */
==================
August 6th, 2009 at 2:58 pm
Struggling for ages with this - thanks so much
the site in question
September 1st, 2009 at 11:41 am
Many thanks indeed!
September 6th, 2009 at 10:18 pm
Hey so much thanks for this….i was in so much trouble due to this prob….thanx again
October 5th, 2009 at 8:19 am
Thanks! This worked perfectly… If only the same could be said about IE.
October 6th, 2009 at 2:43 am
Just had to swing by and say THANKS! Your suggestion plu:
line-height: 999px; /* Set it higher than your image height */
overflow: hidden; /* Hide the text */
font-size: 0; /* FF2 doesn’t like the above */
did the trick.
October 6th, 2009 at 7:23 am
this was a bit of a lifesaver. thank you.
October 21st, 2009 at 7:04 am
this seems to work for me in IE7, which is great, but not in IE6… any ideas?
October 21st, 2009 at 7:59 am
@R I had the same problem on a project, I think it was because of other things being absolutely/or relatively positioned on the page before the button. I am not sure though, IE is sometimes a quandary with it’s screw ups.
Try this as an alternate, that’s what I had to do on a project:
==================
line-height: 999px; /* Set it higher than your image height */
overflow: hidden; /* Hide the text */
font-size: 0; /* FF2 doesn’t like the above */
==================