← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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