← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 257 · 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 colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    h1 { color: purple; }
    #hero { color: white; }
    (a) purple (b) green (c) white (d) orange
  2. 2.What does background-color do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) picks the font style
  3. 3.✍️ What is the selector in this CSS rule?
    .box {
      background-color: yellow;
      font-size: 20px;
    }
    (a) 20px (b) h2 (c) .box (d) background-color
  4. 4.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or narrower (d) 600px or wider
  5. 5.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  6. 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the later one (d) the first one
  7. 7.🧩 Which language changes the text size? (a) HTML (b) CSS (c) JavaScript
  8. 8.🖌️ Which CSS property centres a heading? (a) font-size (b) font-weight (c) text-align (d) background-color
  9. 9.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 32px;
      }
    }
  10. 10.🖌️ What colour is behind the letters?
    h1 {
      font-size: 24px;
      background-color: blue;
      text-align: center;
      color: purple;
    }
    (a) blue (b) purple (c) green
  11. 11.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 210px;
      padding: 30px;
      border: 5px solid black;
      margin: 5px;
    }
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="red" id="logo">Hi</h1>
    CSS:
    .red { color: red; }
    .red { color: green; }
    (a) white (b) blue (c) green (d) red
  13. 13.True or false: #logo is an id selector. (a) True (b) False
  14. 14.🖌️ Which CSS property colours behind the text? (a) font-family (b) text-align (c) background-color (d) font-weight
  15. 15.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 120px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  16. 16.True or false: the content is the line round the box. (a) True (b) False
  17. 17.🌈 Which colour is #ff0000? (a) magenta (b) red (c) black (d) cyan
  18. 18.🌈 In #0000f4 the blue part is the hex number f4. What is it as a normal number?
  19. 19.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) reacts to a button click (d) gives the page structure
  20. 20.💪 Which flexbox property turns on flexbox? (a) justify-content (b) flex-direction (c) gap (d) display: flex
  21. 21.🌈 Which hex code is bright green? (a) #ff0000 (b) #00ff00 (c) #ff00ff (d) #0000ff
  22. 22.🎯 Which CSS selector matches this element?
    <span class="note" id="main">Hello</span>
    (a) #main (b) #note (c) p (d) .big
  23. 23.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    .red { color: orange; }
    h2 { color: red; }
    (a) green (b) orange (c) red (d) blue
  24. 24.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      margin: 10px;
      padding: 8px;
      width: 300px;
      border: 2px solid;
    }
  26. 26.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 26px;
      }
    }
    (a) No (b) Yes
  27. 27.✍️ Which property is set to 20px in this rule?
    .box {
      font-weight: bold;
      background-color: yellow;
      text-align: center;
      font-size: 20px;
    }
    (a) background-color (b) 20px (c) text-align (d) font-size
  28. 28.🎯 Which element does the selector .menu style? (a) <span class="note"> (b) <span class="menu"> (c) <p class="big"> (d) <span id="menu">
  29. 29.✍️ What is the selector in this CSS rule?
    li {
      font-weight: bold;
      font-size: 20px;
      text-align: center;
    }
    (a) body (b) font-weight (c) 20px (d) li
  30. 30.🎯 Which element does the selector #intro style? (a) <li class="red"> (b) <h2 id="main"> (c) <h2 id="intro"> (d) <h2 class="intro">
  31. 31.True or false: padding is the gap round content. (a) True (b) False
  32. 32.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 210px;
      padding: 30px;
      border: 2px solid black;
      margin: 5px;
    }
  33. 33.Which of these is padding? (a) the gap to other boxes (b) the gap round content (c) the line round the box (d) the text or picture
  34. 34.🔍 Which is the odd one out? (a) makes a form box (b) makes a link (c) gives the page structure (d) changes the text size
  35. 35.🎯 Which CSS selector matches this element?
    <li class="box" id="main">Hello</li>
    (a) #box (b) div (c) .main (d) .box
  36. 36.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) adds space around boxes (d) checks a quiz answer
  37. 37.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    #top { color: black; }
    #top { color: orange; }
    (a) black (b) blue (c) green (d) orange
  38. 38.Which of these does JavaScript do? (a) puts a picture on a page (b) makes a link (c) reacts to a button click (d) adds space around boxes
  39. 39.True or false: the border is the line round the box. (a) False (b) True
  40. 40.True or false: #logo is a class selector. (a) False (b) True

Answer key

  1. white
  2. colours behind the text
  3. .box
  4. 600px or narrower
  5. 10
  6. the later one
  7. CSS
  8. text-align
  9. 32
  10. blue
  11. 290
  12. green
  13. True
  14. background-color
  15. 20
  16. False
  17. red
  18. 244
  19. gives the page structure
  20. display: flex
  21. #00ff00
  22. #main
  23. orange
  24. /*
  25. 4
  26. No
  27. font-size
  28. <span class="menu">
  29. li
  30. <h2 id="intro">
  31. True
  32. 284
  33. the gap round content
  34. changes the text size
  35. .box
  36. adds space around boxes
  37. orange
  38. reacts to a button click
  39. True
  40. False

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