← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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