← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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