← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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