← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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