Skip to main content

CSS ID Selector — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the CSS ID Selector lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.

Exercises(5)

  1. 1

    Target an id

    easy10 min

    Make #one red.

  2. 2

    Border a single element

    easy10 min

    Give #one a 4px solid border.

  3. 3

    Combine id with element

    easy10 min

    Target the div that has the id one.

  4. 4

    Style a descendant of an id

    easy10 min

    Make the paragraph inside #one blue.

  5. 5

    Beat a class rule

    medium10 min

    The id rule should win over the class rule.

Find the bug(5)

  1. 1

    Fix the missing hash

    easy8 min

    An id selector needs a leading #.

  2. 2

    Fix the dot used for an id

    easy8 min

    A dot targets a class, not an id.

  3. 3

    Fix the id that does not exist

    easy8 min

    No element has the id "two".

  4. 4

    Fix the missing descendant space

    easy8 min

    Without a space this looks for one element with both.

  5. 5

    Fix the class expected to beat the id

    easy8 min

    An id always outranks a class.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace