← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 980 · 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.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 30px;
      border: 1px solid black;
      margin: 0px;
    }
  2. 2.✍️ What value is given to font-size in this rule?
    li {
      border: 2px solid;
      font-size: 20px;
      margin: 10px;
      padding: 8px;
    }
    (a) center (b) yellow (c) 20px (d) font-size
  3. 3.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 24px;
      }
    }
    (a) Yes (b) No
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      padding: 8px;
      text-align: center;
    }
  5. 5.🧩 Which language gives the page structure? (a) HTML (b) CSS (c) JavaScript
  6. 6.✍️ CSS declarations go inside which brackets? (a) [ ] (b) ( ) (c) { } (d) < >
  7. 7.🔍 Which is the odd one out? (a) checks a quiz answer (b) makes a form box (c) puts a picture on a page (d) makes headings and lists
  8. 8.✍️ What is the selector in this CSS rule?
    .box {
      color: red;
      background-color: yellow;
      text-align: center;
    }
    (a) h2 (b) yellow (c) color (d) .box
  9. 9.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) href (d) style
  10. 10.⚖️ What colour is the text of this element?
    <h2 class="big" id="intro">Hi</h2>
    CSS:
    h2 { color: yellow; }
    h2 { color: blue; }
    (a) red (b) yellow (c) green (d) blue
  11. 11.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
  12. 12.True or false: margin is the gap to other boxes. (a) True (b) False
  13. 13.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) flex-start (d) center
  14. 14.🖌️ How big is the text, in px?
    li {
      font-size: 16px;
      color: green;
      background-color: orange;
      text-align: left;
    }
  15. 15.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      margin: 10px;
    }
  16. 16.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  17. 17.🌈 Which colour is #ffffff? (a) blue (b) bright green (c) cyan (d) white
  18. 18.🎯 Which CSS selector matches this element?
    <p class="box" id="intro">Hello</p>
    (a) #main (b) h1 (c) #box (d) .box
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 500px;
      justify-content: center;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  20. 20.✍️ In color: blue; which part is the property? (a) : (b) color (c) blue (d) ;
  21. 21.📦 In the box model, which part is space outside the border? (a) padding (b) content (c) border (d) margin
  22. 22.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 100 (c) 1000 (d) 255
  23. 23.True or false: #main is a class selector. (a) False (b) True
  24. 24.📦 In the box model, which part is the gap to other boxes? (a) content (b) border (c) margin (d) padding
  25. 25.✍️ What is the selector in this CSS rule?
    .note {
      width: 300px;
      font-size: 20px;
      background-color: yellow;
      text-align: center;
    }
    (a) .note (b) #top (c) width (d) 20px
  26. 26.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 20px;
      border: 3px solid black;
      margin: 5px;
    }
  27. 27.✍️ Which property is set to red in this rule?
    p {
      color: red;
      text-align: center;
      width: 300px;
      border: 2px solid;
    }
    (a) font-size (b) red (c) text-align (d) color
  28. 28.🎯 Which sign starts a class selector? (a) # (b) & (c) @ (d) .
  29. 29.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) magenta (c) yellow (d) black
  30. 30.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 18px;
      }
    }
  31. 31.✍️ Which property is set to bold in this rule?
    p {
      font-weight: bold;
      font-style: italic;
      padding: 8px;
    }
    (a) width (b) font-weight (c) bold (d) border
  32. 32.🖌️ How big is the text, in px?
    h1 {
      background-color: green;
      font-size: 28px;
      color: orange;
      text-align: right;
    }
  33. 33.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
  34. 34.🎯 How many elements on a page should have the same id? (a) 1 (b) 2 (c) 5 (d) any number
  35. 35.🖌️ Where does the text sit on its line?
    h2 {
      text-align: left;
      color: red;
      background-color: green;
      font-size: 28px;
    }
    (a) in the middle (b) on the right (c) on the left
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="big" id="logo">Hi</h1>
    CSS:
    h1 { color: green; }
    h1 { color: yellow; }
    (a) blue (b) green (c) yellow (d) orange
  37. 37.✍️ What is the selector in this CSS rule?
    h2 {
      font-weight: bold;
      padding: 8px;
      color: red;
      width: 300px;
    }
    (a) font-weight (b) 8px (c) h2 (d) h1
  38. 38.🔍 Which is the odd one out? (a) makes headings and lists (b) counts down a timer (c) makes a form box (d) puts a picture on a page
  39. 39.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    .menu { color: purple; }
    #logo { color: green; }
    h1 { color: blue; }
    (a) blue (b) purple (c) black (d) green
  40. 40.🎯 Which element does the selector .big style? (a) <li id="big"> (b) <li class="big"> (c) <div class="box"> (d) <li class="red">

Answer key

  1. 222
  2. 20px
  3. No
  4. 2
  5. HTML
  6. { }
  7. checks a quiz answer
  8. .box
  9. style
  10. blue
  11. the later one
  12. True
  13. flex-end
  14. 16
  15. 1
  16. an element selector
  17. white
  18. .box
  19. 50
  20. color
  21. margin
  22. 255
  23. False
  24. margin
  25. .note
  26. 256
  27. color
  28. .
  29. magenta
  30. 18
  31. font-weight
  32. 28
  33. /*
  34. 1
  35. on the left
  36. yellow
  37. h2
  38. counts down a timer
  39. green
  40. <li class="big">

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