← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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