← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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