Lesson 6 of 8

Pseudo-elements

Goal

Decoration and states without new tags

01

Explanation

::before and ::after are called pseudo-elements. CSS creates them inside an element, before or after its content, without you writing a tag for them in the HTML. They're used for decoration, like an arrow, a quotation mark or a small icon: anything that adds no meaning to the content.

The first trap is the content property: without it nothing shows up, so you always write it, even as an empty string: content: "". The second trap is that they're inline by default, and an inline element doesn't accept transform, so you write the motion and nothing moves until you make it inline-block.

Then come the states: :hover is for people using a mouse, and :focus-visible is for people navigating with the keyboard. The second one applies when you press Tab but not when you click with the mouse, so you have no excuse for removing the focus outline.

02

Your task

Add the arrow ↓ before the text of .download with ::before and make it inline-block, move it with transform on :hover, and give the link a visible outline on :focus-visible.

Checks

4 checks
  1. The ::before pseudo-element shows the arrow
  2. The arrow is inline-block so it can move
  3. The :hover state moves the arrow with transform
  4. The :focus-visible state draws a visible outline
03

Hints

0/3
Track lessons0 of 8 done

Go deeper into the box model, custom properties, positioning, container queries and more, so you understand what's really going on behind the styles you see.

Intermediate level, 8 lessons, 1.5 hours in total.

index.html
Preview
index.html100%
–/4

Press “Run and check” to grade your code.

4 checks listed under “Your task”.

Track lessons0 of 8 done

Go deeper into the box model, custom properties, positioning, container queries and more, so you understand what's really going on behind the styles you see.

Intermediate level, 8 lessons, 1.5 hours in total.