← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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