← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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