← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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