← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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