← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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