← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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