CSS | ::before selector
::before selector is used to add the same content multiple times before the content of other elements. This selector is same as ::after selector.
Syntax:
::before{
content:
}
Below HTML/CSS code shows the functionality of ::before selector :
<!DOCTYPE html> <html> <head> <style> p::before { content: " - Remember this"; background-color: blue; } </style> </head> <body> <h3>After Selector</h3> <p>User ID: @dmor1</p> <p>Name: dharam</p> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers
Note: Internet Explorer 8 and Opera 4-6 supports with single-colon.(:after)
Recommended Posts:
- CSS | * Selector
- CSS | ::after Selector
- CSS | :not Selector
- CSS | #id Selector
- CSS | Class Selector
- CSS | ::first-letter Selector
- CSS | ::first-line Selector
- CSS | :indeterminate Selector
- CSS | [attribute$=value] Selector
- CSS | :nth-last-child() Selector
- CSS | :nth-child() Selector
- CSS | optional Selector
- CSS | :target Selector
- CSS | :first-of-type Selector
- CSS | :default Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



