← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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