Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Content attribute for IMG tag

Tags:

css

img:after {
   content:attr(title);
}

This is not working, probably because the img tag is empty, no closing tag. Any workaround to fix this without js?

like image 436
passatgt Avatar asked May 15 '11 14:05

passatgt


1 Answers

img is a replaced element, and the w3c 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.

I don't know about any "future specification" that took place. It does not work in Chrome, that's for sure :).

like image 124
kapa Avatar answered Oct 16 '22 01:10

kapa