CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS ::before Selector


What is ::before Selector?

CSS ::before element selector add the content to the beginning of parent element.
Added new content will inherited of parent properties.

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 3.5+
  • Internet Explorer 9+
  • Opera 9.5+
  • Safari 1.3+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.

Syntax

General syntax of ::before selector,

/* CSS2 syntax */
element:before {
	property: value;
	property: value;
	...
}

/* CSS3 syntax */
element::before {
	property: value;
	property: value;
	...
}

Example:

CSS :before selector add the content to the beginning of parent element.

<style type="text/css">
    p.image::before{
        content: "Before Word - ";
        color: #FF0000;
    }
</style>
</head>
<body>

    <p class="image">Example is ::before Pseudo Elements </p>

</body>

Run it...   »

Example Result: