← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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