← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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