← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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