← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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