← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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