← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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