← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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