← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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