← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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