CSS Reference

pseudo-elements

A CSS pseudo-element is a keyword added to a selector that defines a style to a specific part of the selected element.

November 3, 2022

pseudo-element

pseudo-elements

While pseudo-classes style the special state of an element, pseudo-elements define the style of the specific element parts, such as first letter, first line or content inserted before or after an element.

Examples

/* style the first letter of every paragraph */ p::first-letter { color: red; font-size: 110%; }

Pseudo-elements

pseudo-element Description
::before used to style and add something before the element's content
::after used to style and add something after the element's content
::selection used to style the area of an element selected by the user
::first-letter sets style of the first letter of the text
::first-line sets style of the first line of the text
::file-selector-button represents the button of an input file type
::marker selects the marker box of a list item (e.g. bullet or number)

Related Content

Easy Way to Fix Anchor Links Scrolling Too Far

Stories

Easy Way to Fix Anchor Links Scrolling Too Far

Fixed navbar is a very popular way of displaying navigation when a page is scrolled, but you could run into a small detail that needs to be addressed.

How to Avoid Page Flickering When Scrollbars are Dynamically Shown or Hidden?

Stories

How to Avoid Page Flickering When Scrollbars are Dynamically Shown or Hidden?

There are certain cases when you want to dynamically manipulate the page height which will result in flickering.

Changing the Mouse Cursor in CSS With the cursor Property

Stories

Changing the Mouse Cursor in CSS With the cursor Property

Using CSS to change the cursor on your website is a great way to add a little bit of personality to your site.