← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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