← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 944 · 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.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 20px;
      text-align: right;
      color: white;
      background-color: orange;
    }
    (a) on the left (b) on the right (c) in the middle
  2. 2.📦 In the box model, which part is a solid or dotted edge? (a) content (b) border (c) padding (d) margin
  3. 3.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    h2 { color: blue; }
    h2 { color: black; }
    (a) red (b) blue (c) black (d) purple
  4. 4.💪 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 50px wide (no margins).
  5. 5.🌈 Which colour of light is strongest in rgb(67, 49, 222)? (a) blue (b) green (c) red
  6. 6.🖌️ Where does the text sit on its line?
    li {
      background-color: white;
      text-align: center;
      font-size: 40px;
      color: green;
    }
    (a) on the left (b) in the middle (c) on the right
  7. 7.🌈 Which colour is #000000? (a) yellow (b) blue (c) magenta (d) black
  8. 8.✍️ What is the selector in this CSS rule?
    p {
      width: 300px;
      font-weight: bold;
      text-align: center;
      border: 2px solid;
    }
    (a) .note (b) bold (c) p (d) width
  9. 9.🎯 Which CSS selector matches this element?
    <span class="star" id="main">Hello</span>
    (a) #logo (b) #main (c) #star (d) .menu
  10. 10.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 320px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  11. 11.True or false: .big is an element selector. (a) False (b) True
  12. 12.🌈 Which colour of light is strongest in rgb(75, 138, 218)? (a) red (b) blue (c) green
  13. 13.🔍 Which is the odd one out? (a) sets colours and fonts (b) shows a pop-up message (c) lays out the page (d) adds space around boxes
  14. 14.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 110px;
      padding: 10px;
      border: 3px solid black;
      margin: 0px;
    }
  15. 15.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="logo"> (c) <div class="menu"> (d) <h2 class="menu">
  16. 16.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
  17. 17.True or false: padding is space outside the border. (a) True (b) False
  18. 18.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: center;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  20. 20.🖌️ What colour is behind the letters?
    h2 {
      font-size: 40px;
      color: red;
      text-align: right;
      background-color: blue;
    }
    (a) purple (b) red (c) blue
  21. 21.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
  22. 22.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
  23. 23.🎯 Which element does the selector p style? (a) <p class="menu"> (b) <h1> (c) <h2 class="menu"> (d) <li id="intro">
  24. 24.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 300px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  25. 25.✍️ In color: blue; which part is the property? (a) ; (b) : (c) blue (d) color
  26. 26.⚖️ What colour is the text of this element?
    <h1 class="note" id="intro">Hi</h1>
    CSS:
    #intro { color: yellow; }
    #intro { color: purple; }
    (a) orange (b) purple (c) white (d) yellow
  27. 27.🎯 What kind of selector is li? (a) an element selector (b) a class selector (c) an id selector
  28. 28.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  29. 29.🎯 Which element does the selector p style? (a) <p class="red"> (b) <li id="end"> (c) <h1> (d) <h2 class="red">
  30. 30.📱 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;
      }
    }
  31. 31.Which of these does CSS do? (a) gives the page structure (b) sets colours and fonts (c) makes headings and lists (d) makes a form box
  32. 32.🌈 Which hex code is bright green? (a) #00ffff (b) #ffff00 (c) #00ff00 (d) #000000
  33. 33.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-weight: bold;
      font-style: italic;
      padding: 8px;
      background-color: yellow;
    }
  34. 34.Which of these does HTML do? (a) changes the page live (b) gives the page structure (c) checks a quiz answer (d) lays out the page
  35. 35.🎨 What does CSS stand for? (a) Creative Sheet System (b) Colourful Site Styles (c) Cascading Style Sheets (d) Computer Style Sheets
  36. 36.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: green; }
    #intro { color: black; }
    p { color: orange; }
    (a) green (b) black (c) red (d) orange
  37. 37.What does text-align do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) colours behind the text
  38. 38.What does font-size do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) picks the font style
  39. 39.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) neither (d) the later one
  40. 40.True or false: .card is an id selector. (a) False (b) True

Answer key

  1. on the right
  2. border
  3. black
  4. 60
  5. blue
  6. in the middle
  7. black
  8. p
  9. #main
  10. 60
  11. False
  12. blue
  13. shows a pop-up message
  14. 136
  15. <h2 class="menu">
  16. an element selector
  17. False
  18. 22
  19. 40
  20. blue
  21. equal gaps, none at ends
  22. HTML
  23. <p class="menu">
  24. 20
  25. color
  26. purple
  27. an element selector
  28. an element selector
  29. <p class="red">
  30. 32
  31. sets colours and fonts
  32. #00ff00
  33. 4
  34. gives the page structure
  35. Cascading Style Sheets
  36. black
  37. centres a heading
  38. makes letters bigger
  39. the later one
  40. False

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