← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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