← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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