← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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