Quick guide to understand ::after ::before Pseudo elements in CSS

Photo by Greg Rakozy on Unsplash

Quick guide to understand ::after ::before Pseudo elements in CSS

·

1 min read

Hello! Everyone I hope you all are doing great today. Now lets understand what are pseudo elements in CSS. Pseudo elements are basically used to style specific parts of an element like inserting a content before or after an element or to style a particular element.

lets understand this with an quick example

html code

<body>
    <h1>Pseudo</h1>
</body>

CSS code

h1::after{
    content:"after"; 
}

Using ::after will place the element inside content just after h1 Output:

Pseudostart

& if we use

CSS code

h1::before{
    content:"before"; 
}

then output will be

beforePseudo

There are many other pseudo elements such as

::first-letter

::first-line

::file-selector-button

& many more check here