← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 237 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.🎯 What kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector
  2. 2.🖌️ What colour is behind the letters?
    h2 {
      font-size: 20px;
      color: green;
      text-align: center;
      background-color: red;
    }
    (a) green (b) white (c) red
  3. 3.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    p { color: green; }
    .note { color: black; }
    (a) blue (b) green (c) yellow (d) black
  4. 4.True or false: margin is space inside the border. (a) True (b) False
  5. 5.🌈 Which colour of light is strongest in rgb(46, 190, 41)? (a) green (b) red (c) blue
  6. 6.🌈 Which hex code is red? (a) #00ff00 (b) #00ffff (c) #ffffff (d) #ff0000
  7. 7.🎯 Which element does the selector #end style? (a) <div id="hero"> (b) <div class="end"> (c) <span class="big"> (d) <div id="end">
  8. 8.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-size: 20px;
      border: 2px solid;
      background-color: yellow;
      text-align: center;
    }
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      width: 300px;
      border: 2px solid;
      padding: 8px;
    }
  10. 10.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
  11. 11.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      font-size: 20px;
      width: 300px;
    }
  12. 12.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 160px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  13. 13.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: black; }
    (a) black (b) yellow (c) orange (d) purple
  14. 14.🖌️ Which CSS property centres a heading? (a) text-align (b) color (c) font-family (d) font-weight
  15. 15.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    #end { color: orange; }
    #end { color: white; }
    (a) white (b) red (c) orange (d) blue
  16. 16.✍️ Which sign goes between a property and its value? (a) = (b) : (c) ; (d) -
  17. 17.🌈 In #000046 the blue part is the hex number 46. What is it as a normal number?
  18. 18.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) green (d) red
  19. 19.🖌️ How big is the text, in px?
    h2 {
      text-align: right;
      font-size: 20px;
      color: orange;
      background-color: red;
    }
  20. 20.🌈 Which colour is rgb(0, 255, 255)? (a) red (b) black (c) magenta (d) cyan
  21. 21.📦 In the box model, which part is the gap round content? (a) content (b) margin (c) border (d) padding
  22. 22.🎯 Which element does the selector span style? (a) <p> (b) <h2 id="hero"> (c) <h1 class="note"> (d) <span class="note">
  23. 23.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    #top { color: white; }
    h1 { color: black; }
    .box { color: green; }
    (a) green (b) white (c) black (d) red
  24. 24.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
  25. 25.What does text-align do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) centres a heading
  26. 26.✍️ Which property is set to 10px in this rule?
    #top {
      margin: 10px;
      width: 300px;
    }
    (a) font-weight (b) margin (c) 10px (d) padding
  27. 27.True or false: the content is the gap round content. (a) False (b) True
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="star" id="intro">Hi</h2>
    CSS:
    h2 { color: red; }
    .star { color: yellow; }
    (a) blue (b) yellow (c) green (d) red
  29. 29.Which of these is margin? (a) space inside the border (b) a solid or dotted edge (c) the gap to other boxes (d) the text or picture
  30. 30.🌈 Which hex code is bright green? (a) #ffffff (b) #00ffff (c) #00ff00 (d) #ff0000
  31. 31.✍️ Which property is set to 300px in this rule?
    p {
      color: red;
      width: 300px;
    }
    (a) 300px (b) font-style (c) width (d) color
  32. 32.✍️ How does a CSS comment start? (a) // (b) <!-- (c) /* (d) #
  33. 33.🌈 Which hex code is magenta? (a) #ff00ff (b) #ff0000 (c) #0000ff (d) #ffffff
  34. 34.🌈 Which colour of light is strongest in rgb(177, 7, 8)? (a) red (b) green (c) blue
  35. 35.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  36. 36.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 5px;
      border: 5px solid black;
      margin: 10px;
    }
  37. 37.🎯 Which element does the selector .big style? (a) <p class="box"> (b) <span id="big"> (c) <span class="red"> (d) <span class="big">
  38. 38.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
  39. 39.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      color: red;
      padding: 8px;
    }
  40. 40.✍️ What is the selector in this CSS rule?
    p {
      font-weight: bold;
      color: red;
      background-color: yellow;
    }
    (a) font-weight (b) .note (c) red (d) p

Answer key

  1. an id selector
  2. red
  3. black
  4. False
  5. green
  6. #ff0000
  7. <div id="end">
  8. 4
  9. 3
  10. the viewport meta tag
  11. 2
  12. 80
  13. black
  14. text-align
  15. white
  16. :
  17. 70
  18. red
  19. 20
  20. cyan
  21. padding
  22. <span class="note">
  23. white
  24. JavaScript
  25. centres a heading
  26. margin
  27. False
  28. yellow
  29. the gap to other boxes
  30. #00ff00
  31. width
  32. /*
  33. #ff00ff
  34. red
  35. 20
  36. 100
  37. <span class="big">
  38. equal gaps, none at ends
  39. 2
  40. p

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