← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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