Search code examples
htmlcsswebkithtml-email

How to remove borders around broken images in webkit?


Can anybody advise me on this? WebKit browsers keeps on putting a gray 1px border around disabled images. The reason I need this removed is for email optimization for when email clients have images disabled. Works fine in Firefox, but WebKit browsers keep showing the border.

I have tried border:none !important everywhere including inline, but Chrome/Safari are being stubborn.

Edit: Here is sample html with inline css

<img style="outline:none;text-decoration:none;display:block;border:none;-webkit-border:0;" border="0" src="images/rm_bnk.gif" width="10" height="10" alt="test" />

Solution

  • There is no way to remove it but I wrapped the image in an element that has overflow hidden property in its styles.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>Hide Broken Image border</title>
      <style>
        body{
          background-color:azure;
        }
        .image-container{
          width:100px;
          height:100px;
          overflow:hidden;
          display:block;
          background-color:orange; /*not necessary, just to show the image box, can be added to img*/
        }
        .image-container img{
          margin:-1px;
        }
      </style>
    </head>
    <body>
      <span class="image-container">
        <img src="path-to-image" alt="I'm Broken :(" width="102" height="102">
      </span>
    </body>
    </html>
    

    Take a look at this bin http://jsbin.com/OpAyAZa/1/edit