← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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