← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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