← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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