← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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