I am trying to use a :before
pseudo element with an img
element.
Consider this HTML and CSS...
<img src="http://0.gravatar.com/avatar/this-is-not-a-hash" alt="" />
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?
Note. This specification does not fully define the interaction of
:before
and:after
with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.
I guess this means they don't work with img
elements (for now).
Also see this answer.