As answered in this question.
Using before
and after
psuedo-elements with the img
tag does not work in most browsers, by design.
Image tags are self-closing (<tag />
) tags because they contain no content. Since they do not contain any content, no generated content can be appended (::after
) or prepended (::before
) to the existing content.
The article linked above lists two work-around solutions. The CSS work-around is very hackish in nature, while the jQuery solution is much more elegant, but depends on both Javascript being enabled and the jQuery library being included.