← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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