← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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