← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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