← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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