-1

I was going through different video tutorials and a few suggested to use ::before pseudo selector to apply background image.

Is there any specific reason to follow this trend?

Anand
  • 222
  • 3
  • 12

1 Answers1

1

It is really a personal preference. Using ::before and ::after pseudo elements in this case allows you to insert images without the need for adding extra html elements.

Here is an example by Bryan Robinson of its clever usage

You can see how it can be used to create a three layered image background with just a single html element.

saraserin
  • 170
  • 1
  • 6