← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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