← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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