← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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