:before Pseudo Element trong CSS



:before Pseudo Element trong CSS

:before Pseudo Element trong CSS để chèn một số nội dung vào trước một phần tử nào đó (ví dụ chèn các bullet).

Ví dụ :before Pseudo Element trong CSS

Bạn theo dõi ví dụ sau để thấy cách sử dụng của :before Pseudo Element trong CSS.

<html>
   <head>
      <style type="text/css">
         p:before {
            content: url(/images/bullet.gif)
         }
      </style>
   </head>
   <body>
      <p> Dong text nay se duoc dat truoc boi mot Bullet.</p>
      <p> Dong text nay se duoc dat truoc boi mot Bullet.</p>
      <p> Dong text nay se duoc dat truoc boi mot Bullet.</p>
   </body>
</html> 
Quảng cáo

Kết quả là: