← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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