This question already has an answer here:
I need to define an <img>'s src attribute in CSS. Is there a way to specify this attribute?
This question already has an answer here:
I need to define an <img>'s src attribute in CSS. Is there a way to specify this attribute?
After trying these solutions I still wasn't satisfied but I found a solution in this article and it works in Chrome, Firefox, Opera, Safari, IE8+
They are right. IMG is a content element and CSS is about design. But, how about when you use some content elements or properties for design purposes? I have IMG across my web pages that must change if i change the style (the CSS).
Well this is a solution for defining IMG presentation (no really the image) in CSS style.
1: create a 1x1 transparent gif or png.
2: Assign propery "src" of IMG to that image.
3: Define final presentation with "background-image" in the CSS style.
It works like a charm :)
No. The closest you can get is setting a background image:
just this as img tag is a content element
No there isn't. You can specify a background image but that's not the same thing.