← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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