← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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