← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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