Why don't :before and :after pseudo elements work with `img` elements? [duplicate]
-
29-10-2019 - |
Question
This question already has an answer here:
- Does :before not work on img elements? 11 answers
- CSS :after not adding content to certain elements 3 answers
I am trying to use a :before
pseudo element with an img
element.
Consider this HTML and CSS...
HTML
<img src="http://0.gravatar.com/avatar/this-is-not-a-hash" alt="" />
CSS
img:before {
content: "hello";
}
This does not produce the desired effect (tested in Chrome 13 and Firefox 6). However, it works with a div
or span
element.
Why not?
Is there a way to make pseudo elements work with img
elements?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow