Home HTML/CSS CSS :before Selector
Author:

I'm sure of you, not everyone knows the utility and functionality of attributes :before in css. In this turorial, 
you will learn how to use :before very simple and effective in many contexts. 

If you want to insert a sentence or content before every paragraph in your page.

Here's sample:

p:before{

content: "Read this carefully"; /*Insert content here*/

background: #000

color: #ff0000

font-size: 13px;

}

 

Now, before every <p> elements, the content "Read this carefully" is added . You can add style for the content by do the above attributes 
(background, color, font-size, font-weight..ect ) 

The :before does support in all major browsers.

Note: For :before to work in IE8, a <!DOCTYPE> must be declared. 

Did you like this tip 



Comments (0)
Write comment
Your Contact Details:
Comment:
Security
Please input the anti-spam code that you can read in the image.

"