← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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