← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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