← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 275 · 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.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
  2. 2.✍️ Which property is set to 300px in this rule?
    .box {
      width: 300px;
      text-align: center;
      padding: 8px;
    }
    (a) color (b) 300px (c) font-style (d) width
  3. 3.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) red (d) blue
  4. 4.⚖️ 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
  5. 5.True or false: margin is space outside the border. (a) False (b) True
  6. 6.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  7. 7.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) space-between (d) flex-start
  8. 8.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 460px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  9. 9.✍️ What is the selector in this CSS rule?
    p {
      text-align: center;
      background-color: yellow;
      border: 2px solid;
      font-size: 20px;
    }
    (a) yellow (b) .note (c) text-align (d) p
  10. 10.🖌️ What colour is behind the letters?
    h1 {
      text-align: center;
      background-color: blue;
      font-size: 24px;
      color: white;
    }
    (a) purple (b) white (c) blue
  11. 11.✍️ What value is given to color in this rule?
    .note {
      font-weight: bold;
      color: red;
    }
    (a) color (b) 20px (c) red (d) center
  12. 12.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
  13. 13.🎨 A CSS file usually ends with which extension? (a) .png (b) .js (c) .html (d) .css
  14. 14.🎯 Which element does the selector h1 style? (a) <h2> (b) <li class="box"> (c) <div id="intro"> (d) <h1 class="box">
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="box" id="hero">Hi</h2>
    CSS:
    h2 { color: orange; }
    #hero { color: black; }
    .box { color: green; }
    (a) green (b) orange (c) black (d) blue
  16. 16.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) 2 (d) any number
  17. 17.🎨 Which tag connects an outside CSS file? (a) <img> (b) <css> (c) <link> (d) <a>
  18. 18.🎨 One CSS file can style how many pages? (a) many pages (b) only one word (c) no pages (d) only one image
  19. 19.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  20. 20.🌈 In #070000 the red part is the hex number 07. What is it as a normal number?
  21. 21.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) flex-start (d) center
  22. 22.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
  23. 23.🎯 Which CSS selector matches this element?
    <h2 class="box" id="main">Hello</h2>
    (a) #logo (b) h2 (c) .main (d) li
  24. 24.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
  25. 25.🖌️ What colour is behind the letters?
    h2 {
      font-size: 36px;
      color: yellow;
      text-align: left;
      background-color: red;
    }
    (a) red (b) yellow (c) blue
  26. 26.🔍 Which is the odd one out? (a) gives the page structure (b) changes the text size (c) makes headings and lists (d) makes a link
  27. 27.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    #logo { color: yellow; }
    .note { color: green; }
    p { color: purple; }
    (a) yellow (b) red (c) green (d) purple
  28. 28.True or false: HTML makes a form box. (a) True (b) False
  29. 29.🌈 Which colour is rgb(0, 255, 0)? (a) bright green (b) black (c) red (d) cyan
  30. 30.🌈 Which colour of light is strongest in rgb(116, 237, 108)? (a) blue (b) green (c) red
  31. 31.🌈 Which colour is #ff00ff? (a) bright green (b) blue (c) magenta (d) red
  32. 32.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 420px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  33. 33.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    #top { color: red; }
    #top { color: blue; }
    (a) black (b) green (c) blue (d) red
  34. 34.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    .big { color: red; }
    h1 { color: purple; }
    #top { color: black; }
    (a) red (b) black (c) blue (d) purple
  35. 35.🌈 In #aa0000 the red part is the hex number aa. What is it as a normal number?
  36. 36.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
  37. 37.⚖️ What colour is the text of this element?
    <h1 class="menu" id="top">Hi</h1>
    CSS:
    h1 { color: red; }
    h1 { color: blue; }
    (a) orange (b) blue (c) red (d) yellow
  38. 38.🌈 Which hex code is magenta? (a) #00ff00 (b) #00ffff (c) #ff00ff (d) #000000
  39. 39.📱 What does a media query check? (a) the battery level (b) the screen width (c) the page title (d) the time of day
  40. 40.🖌️ What colour is behind the letters?
    h2 {
      background-color: green;
      text-align: left;
      font-size: 24px;
      color: red;
    }
    (a) red (b) blue (c) green

Answer key

  1. padding
  2. width
  3. red
  4. the later one
  5. True
  6. 18
  7. flex-start
  8. 60
  9. p
  10. blue
  11. red
  12. ;
  13. .css
  14. <h1 class="box">
  15. black
  16. 1
  17. <link>
  18. many pages
  19. an element selector
  20. 7
  21. space-between
  22. 16
  23. h2
  24. 800px or wider
  25. red
  26. changes the text size
  27. yellow
  28. True
  29. bright green
  30. green
  31. magenta
  32. 20
  33. blue
  34. black
  35. 170
  36. 8
  37. blue
  38. #ff00ff
  39. the screen width
  40. green

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