chapeljuice
chapeljuice

Reputation: 886

Using ::before or ::after on an image element?

Do the "::before" and "::after" pseudo elements not work on image elements?

Here's an example I put together...I'm just trying to get a yellow background behind the image here: http://dabblet.com/gist/3861878

I saw this "answered" (but no other details) in another post, but can't seem to find anything about it elsewhere.

Upvotes: 0

Views: 105

Answers (1)

gkond
gkond

Reputation: 4284

CSS 2.1 spec says:

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.

http://www.w3.org/TR/CSS21/generate.html

So it it'd be wise to avoid using this. Behavior across the browsers is uncertain and can change in future.

Upvotes: 2

Related Questions