Removing the image border in Chrome/IE9

It’s a Chrome bug, ignoring the “border:none;” style.

Let’s say you have an image “download-button-102×86.png” which is 102×86 pixels in size. In most browsers, you would reserve that size for its width and height, but Chrome just paints a border there, no matter what you do.

So you trick Chrome into thinking that there is nothing there – size of 0px by 0px, but with exactly the right amount of “padding” to allow for the button. Here is a CSS id block that I am using to accomplish this…

#dlbutn {
    display:block;
    width:0px;
    height:0px;
    outline:none;
    padding:43px 51px 43px 51px;
    margin:0 auto 5px auto;
    background-image:url(/images/download-button-102x86.png);
    background-repeat:no-repeat;
}

Voila! Works everywhere and gets rid of the outline/border in Chrome.

Leave a Comment