← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 528 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  2. 2.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  3. 3.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    #logo { color: purple; }
    #logo { color: green; }
    (a) red (b) purple (c) black (d) green
  4. 4.⚖️ What colour is the text of this element?
    <p class="note" id="end">Hi</p>
    CSS:
    .note { color: green; }
    #end { color: white; }
    (a) green (b) white (c) black (d) blue
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: purple; }
    .big { color: orange; }
    #main { color: black; }
    (a) purple (b) black (c) red (d) orange
  6. 6.⚖️ What colour is the text of this element?
    <h1 class="menu" id="top">Hi</h1>
    CSS:
    #top { color: yellow; }
    .menu { color: purple; }
    (a) purple (b) red (c) blue (d) yellow
  7. 7.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    p { color: black; }
    #intro { color: purple; }
    (a) blue (b) purple (c) red (d) black
  8. 8.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    .red { color: red; }
    .red { color: blue; }
    (a) white (b) blue (c) black (d) red
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="big" id="end">Hi</h2>
    CSS:
    h2 { color: purple; }
    h2 { color: black; }
    (a) black (b) blue (c) orange (d) purple
  10. 10.⚖️ What colour is the text of this element?
    <p class="red" id="hero">Hi</p>
    CSS:
    .red { color: orange; }
    #hero { color: purple; }
    p { color: green; }
    (a) green (b) red (c) purple (d) orange
  11. 11.⚖️ What colour is the text of this element?
    <h1 class="star" id="main">Hi</h1>
    CSS:
    #main { color: white; }
    h1 { color: green; }
    (a) green (b) yellow (c) white (d) black
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    .star { color: purple; }
    h1 { color: white; }
    #logo { color: red; }
    (a) yellow (b) white (c) red (d) purple
  13. 13.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    .menu { color: green; }
    p { color: orange; }
    #top { color: blue; }
    (a) yellow (b) orange (c) blue (d) green
  14. 14.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: yellow; }
    (a) red (b) yellow (c) blue (d) black
  15. 15.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    .red { color: black; }
    p { color: white; }
    (a) red (b) white (c) orange (d) black
  16. 16.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    .box { color: orange; }
    p { color: yellow; }
    #top { color: green; }
    (a) orange (b) blue (c) yellow (d) green
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    h1 { color: yellow; }
    .note { color: blue; }
    (a) black (b) orange (c) yellow (d) blue
  18. 18.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    h2 { color: purple; }
    h2 { color: red; }
    (a) blue (b) red (c) yellow (d) purple
  19. 19.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    p { color: purple; }
    .big { color: green; }
    (a) purple (b) black (c) green (d) yellow
  20. 20.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
  21. 21.⚖️ What colour is the text of this element?
    <p class="star" id="intro">Hi</p>
    CSS:
    .star { color: white; }
    p { color: blue; }
    (a) black (b) blue (c) yellow (d) white
  22. 22.⚖️ What colour is the text of this element?
    <h2 class="red" id="top">Hi</h2>
    CSS:
    .red { color: yellow; }
    .red { color: black; }
    (a) black (b) yellow (c) blue (d) purple
  23. 23.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    p { color: blue; }
    p { color: purple; }
    (a) blue (b) green (c) purple (d) red
  24. 24.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    .menu { color: red; }
    .menu { color: blue; }
    (a) red (b) blue (c) green (d) white
  25. 25.⚖️ What colour is the text of this element?
    <p class="note" id="end">Hi</p>
    CSS:
    p { color: black; }
    p { color: purple; }
    (a) black (b) purple (c) white (d) orange
  26. 26.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    h2 { color: purple; }
    #intro { color: blue; }
    .red { color: yellow; }
    (a) blue (b) yellow (c) purple (d) white
  27. 27.⚖️ What colour is the text of this element?
    <h1 class="star" id="main">Hi</h1>
    CSS:
    #main { color: white; }
    .star { color: yellow; }
    (a) blue (b) yellow (c) orange (d) white
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="red" id="hero">Hi</h2>
    CSS:
    .red { color: blue; }
    .red { color: purple; }
    (a) yellow (b) purple (c) red (d) blue
  29. 29.⚖️ What colour is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    p { color: green; }
    p { color: red; }
    (a) green (b) yellow (c) white (d) red
  30. 30.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: red; }
    (a) purple (b) yellow (c) green (d) red
  31. 31.⚖️ What colour is the text of this element?
    <h1 class="box" id="hero">Hi</h1>
    CSS:
    h1 { color: black; }
    h1 { color: blue; }
    (a) blue (b) red (c) green (d) black
  32. 32.⚖️ What colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    p { color: yellow; }
    .star { color: orange; }
    #hero { color: purple; }
    (a) blue (b) purple (c) yellow (d) orange
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="star" id="intro">Hi</h2>
    CSS:
    .star { color: white; }
    .star { color: black; }
    (a) black (b) white (c) orange (d) blue
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="red" id="logo">Hi</h2>
    CSS:
    #logo { color: blue; }
    .red { color: white; }
    h2 { color: black; }
    (a) black (b) orange (c) blue (d) white
  35. 35.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    p { color: red; }
    .big { color: yellow; }
    (a) yellow (b) blue (c) red (d) black
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="star" id="main">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: orange; }
    (a) white (b) yellow (c) black (d) orange
  37. 37.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    .note { color: red; }
    .note { color: yellow; }
    (a) orange (b) yellow (c) red (d) green
  38. 38.⚖️ What colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    p { color: green; }
    .star { color: blue; }
    (a) white (b) blue (c) green (d) orange
  39. 39.⚖️ What colour is the text of this element?
    <h1 class="box" id="end">Hi</h1>
    CSS:
    #end { color: blue; }
    #end { color: purple; }
    (a) red (b) orange (c) purple (d) blue
  40. 40.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    #main { color: yellow; }
    #main { color: green; }
    (a) white (b) red (c) green (d) yellow

Answer key

  1. an element selector
  2. an id selector
  3. green
  4. white
  5. black
  6. yellow
  7. purple
  8. blue
  9. black
  10. purple
  11. white
  12. red
  13. blue
  14. yellow
  15. black
  16. green
  17. blue
  18. red
  19. green
  20. the later one
  21. white
  22. black
  23. purple
  24. blue
  25. purple
  26. blue
  27. white
  28. purple
  29. red
  30. red
  31. blue
  32. purple
  33. black
  34. blue
  35. yellow
  36. orange
  37. yellow
  38. blue
  39. purple
  40. green

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids