← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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