← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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