← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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