← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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