I\'m trying to use the :before
selector to place an image over another image, but I\'m finding that it simply doesn\'t work to place an image before an im
I think the best way to look at why this doesn't work is that :before and :after insert their content before or after the content within the tag you're applying them to. So it works with divs or spans (or most other tags) because you can put content inside them.
:before
Content
:after
However, an img is a self-contained, self-closing tag, and since it has no separate closing tag, you can't put anything inside of it. (That would need to look like Content
, but of course that doesn't work.)
I know this is an old topic, but it pops up first on Google, so hopefully this will help others learn.