Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" />
like image 395
Van Nguyen Avatar asked Oct 31 '12 04:10

Van Nguyen


People also ask

How do I remove the border from an image in CSS?

Adding border="0" to your img tag prevents that picture from having a border around the image.

How do you remove a border from a picture?

Remove a border from a picture Select the picture whose border you want to remove. On the Page Layout tab, in the Page Background group, select Page Borders. Click the Borders tab. Under Setting, select None.

How do I get rid of side borders?

On the Design tab, choose Page Borders. In the Borders and Shading dialog box, in the Apply to list, choose the page (or pages) you want to remove the border from. Under Setting, choose None. Select OK.


2 Answers

Amit's answer is just great, but a small advice: use visibility: hidden; instead of display: none;

img:not([src]) {
   visibility: hidden;
}
  • so you could save img block size and positioning of other elements. its usefull in most cases, i use it on my sites with images lazyload and show just blank block before the image loads.
like image 89
kabantejay Avatar answered Nov 05 '22 06:11

kabantejay


If img src is not present or broken then use below css code

img:not([src]){ display:none; }

this css hide image till img src is not loaded completely.

like image 43
Amit Avatar answered Nov 05 '22 07:11

Amit