← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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