← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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