← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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