Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pseudo-elements and images

Tags:

html

css

Can an image have pseudo-elements?

In my testing I have not been able to use :before or :after with image elements, but I would love some more information.

EDIT: W3C isn't clear either unfortunately:

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.
like image 338
joshnh Avatar asked Sep 23 '11 00:09

joshnh


1 Answers

It wouldn't really make any sense. The :before and :after insert the extra content inside the matched element, and img doesn't have an inside.

like image 159
Ariel Avatar answered Oct 03 '22 05:10

Ariel