CSS pseudo-after / before using content or background for img?

As with the :after/ pseudo-elements :before, there are apparently two ways if I want to display the image there:

  • using background-image:url(imgurl.png);
  • using content:url(imgurl.png);

Are both ways right and right? Why should I use one path over another?

Apparently, using the second method, you cannot set image properties such as size. But the first method is more general on the Internet.

Ideas?

+4
source share
1 answer

It depends on what your image is, as well as discussions between using a tag <img>and using background-imagein your CSS.

, content:url(imgurl.png);. , , , content. , background-image:url(imgurl.png);

, : ::before ::after. IE8 .

+1

All Articles