← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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