← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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