← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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