← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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