← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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