← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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