What is the use of ::before ::after? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the use of ::before ::after?

When to use them kindly explain with examples for better explanation.

21st Jan 2023, 3:38 PM
Mohammad Arsalan Rather
Mohammad Arsalan Rather - avatar
2 Answers
+ 1
They're pseudo-selectors. With them, you can specify which elements to target in a DOM tree. For example: .fancy-div p::before allows you to target all elements in a fancy-div class that come before p elements. This could be used to apply a bottom margin, fancy bottom border, a background image inside the element, etc.
21st Jan 2023, 4:12 PM
Sam
0
🤔🤔🤔🤔
21st Jan 2023, 5:59 PM
Arturop
Arturop - avatar