CSS TutorialLesson #88

CSS Content

Pseudo-elements for content allow you to insert content before or after elements, style list markers, and more.

Pseudo-elements for Content

Pseudo-elements for content allow you to insert content before or after elements, style list markers, and more.


The CSS ::before Pseudo-element

The ::before pseudo-element is used to insert some content before the content of a specified element.

Use the content property to specify the content to insert.

Example

Example Code

css
Try it Yourself
h3::before
{

  content: url(smiley.gif);

}

The CSS ::after Pseudo-element

The ::after pseudo-element is used to insert some content after the content of a specified element.

Use the content property to specify the content to insert.

Example

Example Code

css
Try it Yourself
h3::after
{

  content: url(smiley.gif);

}

The CSS ::marker Pseudo-element

The ::marker pseudo-element is used to style the list item markers.

Example

Example Code

css
Try it Yourself
::marker {

  color: red;
  font-size: 23px;

}

The CSS ::selection Pseudo-element

The ::selection pseudo-element is used to style the part of a text that is selected by a user.

Example

Example Code

css
Try it Yourself
::selection {
  color: red;

background: yellow;
}

The CSS ::backdrop Pseudo-element

The ::backdrop pseudo-element is used to style the viewbox behind a dialog box or popover element.

Example

Example Code

css
Try it Yourself
dialog::backdrop {
  background-color: lightgreen;
}

CSS Pseudo-elements Reference

For a complete list of all CSS Pseudo-elements, visit our CSS Pseudo-elements Reference.

Interactive Code Examples

CSS Example 1

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 2

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 3

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 4

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 5

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview: