← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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