← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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