← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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