← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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