← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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