← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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