← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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