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?
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?
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.