← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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