← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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