← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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