What are Pseudo-Elements?

A CSS pseudo-element is used to style specified parts of an element.
For example,
  • Style the first letter, or line, of an element
  • Insert content before, or after, the content of an element

Syntax

                 selector::pseudo-element 
                 {                    property:value;                 }
Difference between ::first-line versus :first-line
  • The double colon replaced the single-colon notation for pseudo-elements in CSS3.
  • The single-colon syntax was used for both pseudo-classes and pseudo-elements in CSS2 and CSS1.

The ::first-line Pseudo-element

The ::first-line pseudo-element is used to add a special style to the first line of a text.
Note: The ::first-line pseudo-element can only be applied to block-level elements.
The following properties
  • font properties
  • color properties
  • background properties
  • word-spacing
  • letter-spacing
  • text-decoration
  • vertical-align
  • text-transform
  • line-height
  • clear
The ::first-letter Pseudo-element
The ::first-letter pseudo-element is used to add a special style to the first letter of a text.

Multiple Pseudo-elements

CSS - The ::before Pseudo-element
The ::before pseudo-element can be used to insert some content before the content of an element.
CSS - The ::after Pseudo-element
The ::after pseudo-element can be used to insert some content after the content of an element.

Comments

Popular posts from this blog

Bootstrap Breakpoints