← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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