← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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