← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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