Lesson 7 of 8

Loading skeletons

Goal

Reserve space for content before it arrives

01

Explanation

A blank screen while something loads looks broken, and a spinner on its own doesn't tell the user what's coming. A skeleton is a set of gray blocks with the shape and size of the content on its way, so the user knows what will appear and where, and the page doesn't jump when the content arrives.

A subtle shimmer sweeping across the blocks shows that loading is still in progress. You draw it on ::after as a gradient layer that slides with transform from just outside one edge of the block to just outside the other, and the block keeps it contained with position: relative and overflow: hidden. Endless motion is the first thing to turn off for anyone who asked for reduced motion.

The common mistake is animating background-position instead. It works, but it makes the browser repaint the blocks on every frame, which transform doesn't.

02

Your task

Give .skeleton a gray background, position: relative and overflow: hidden. Draw a gradient on .skeleton::after and move it endlessly with @keyframes that use transform, then stop the motion inside @media (prefers-reduced-motion: reduce).

Checks

6 checks
  1. All three blocks show up in a neutral color
  2. Each block keeps the shimmer contained inside it
  3. Each block has an animated shimmer in ::after
  4. The shimmer moves with transform, without repainting
  5. The shimmer repeats without stopping
  6. The shimmer stops for anyone who asked for reduced motion
03

Hints

0/3
Track lessons0 of 8 done

Learn page layout, form validation, motion and accessibility: the things that make an interface comfortable to use in real life, not just nice to look at.

Advanced level, 8 lessons, 2 hours in total.

index.html
Preview
index.html100%
–/6

Press “Run and check” to grade your code.

6 checks listed under “Your task”.

Track lessons0 of 8 done

Learn page layout, form validation, motion and accessibility: the things that make an interface comfortable to use in real life, not just nice to look at.

Advanced level, 8 lessons, 2 hours in total.