← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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