← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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