← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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