← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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