← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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