← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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