← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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