← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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