← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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