CSS - Pseudo-element :before and :after


Advertisements


The :before element

Description

The :before pseudo-element is used to insert some content before an element.

Example

Following is the example which demonstrates how to use :before element to add some content before any element.

<html>
   <head>
      <style type="text/css">
         p:before {
            content: url(/images/bullet.gif)
         }
      </style>
   </head>
   <body>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
   </body>
</html> 

This will produce following black link −



Advertisements