← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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