HTML & CSS · Middle · Question 64 of 75

How can CSS number headings like "Step 1", "Step 2" automatically?

.steps { counter-reset: step; }
.steps h3::before {
  counter-increment: step;
  content: "Step " counter(step) ": ";
}

Explanation

Counters update automatically when items are added or removed. Generated content in ::before isn't selectable and may not be announced consistently by screen readers, so don't put essential info there.

Further reading

Problem with a question

HTML & CSS · Middle · question 64

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz