← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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