← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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