← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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