← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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