Software Development | CSS Pseudo-Elements

CSS Pseudo-Elements

Overview

Like pseudo-classes, CSS pseudo-elements add versatility when working with HTML and CSS. Pseudo-elements let you style specific parts of an element, and ::before and ::after let you insert content directly before or after an element's content.

"A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). For example, ::first-line can be used to change the font of the first line of a paragraph." – MDN

Prepare

Activity Instructions

  1. Fork the CodePen ☼ CSS Pseudo-Elements to your own CodePen account.
  2. Add a ::marker pseudo-element rule to the CSS.
  3. In the marker rule, add declarations to change the ordered list's numbers:
    1. color: navy
    2. font-size: 2rem
    3. font-variant: small-caps
  4. Add a ::before pseudo-element to insert a check mark ✔ in front of each ordered list item.

    Built-in emoji pickers: Windows (Windows+.) • macOS (Fn/🌐 or Ctrl+Cmd+Space)

Screenshot of the completed pseudo-element CodePen example
Screenshot of the completed pseudo-element CodePen