← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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