← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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