← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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