The ::before the selector is used to inserting something before the content of any selected element. Whereas, the ::after selector to insert something after the content in a specified element.

Syntax for before selector:

::before {
   css declarations;
}

Syntax for After Selector:

::after {
   css declarations;
}

BY Best Interview Question ON 22 Feb 2020

Example

before

p::before {
   content: "Read this -";
   color: red;
   background-color: red;
}

after

p::after {
   content: " - Read this";
   color: red;
   background-color: red;
}