Chrome and Safari are displaying a border around the image, but I don\'t want one. There is no border in Mozilla. I\'ve looked through the CSS and HTML, and I can\'t find an
img[src=""]{
content: "";
}
To summarise the answers given already: your options to remove the grey border from an img:not([src])
, but still display an image using background-image
in Chrome/Safari are:
Use a different tag that doesn't have this behaviour. (Thanks @Druvision)
Eg: div
or span
.
Sad face: it's not quite as semantic.
Use padding
to define the dimensions. (Thanks @Gonzalo)
Eg padding: 16px 10px 1px;
replaces width:20px; height:17px;
Sad face: dimensions and intentions aren't as obvious in the CSS, especially if it's not an even square like @Gonalo's example.
I just added src="trans.png", trans.png is just a 100x100 transparent background png from photoshop. Worked like a charm no borders
Now I don't know if this is a bug with Chrome or not but the grey border appears when it can't find the image, the image url is broken or as in your case the src isn't there. If you give the image a proper URL and the browser finds it then the border goes away. If the image is to not have a src then you will need to remove the height and width.
I have fixed this issue with:
<img src="img/1.jpg" style="height:150px; position: absolute; right: 15px;">
The right: 15px
is where you want the image to be shown, but you can place it where you want.
sarcastyx is right, but if you want a workarround you can set the width and height to 0 and a padding to make space for your image.
If you want a icon of 36x36, you can set width and height to 0 and pading:18px