← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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