joshnh
joshnh

Reputation: 8704

Pseudo-elements and images

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.

Upvotes: 5

Views: 567

Answers (1)

Ariel
Ariel

Reputation: 26753

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.

Upvotes: 6

Related Questions