← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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