← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 580 · 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.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
  2. 2.🖌️ Which CSS property sets the letter colour? (a) color (b) font-size (c) background-color (d) text-align
  3. 3.🖌️ What colour are the letters?
    h2 {
      background-color: blue;
      text-align: center;
      font-size: 24px;
      color: yellow;
    }
    (a) purple (b) yellow (c) blue
  4. 4.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
  5. 5.Which of these is the border? (a) the gap to other boxes (b) the gap round content (c) a solid or dotted edge (d) the text or picture
  6. 6.True or false: CSS reacts to a button click. (a) True (b) False
  7. 7.Which of these is padding? (a) space outside the border (b) a solid or dotted edge (c) space inside the border (d) the line round the box
  8. 8.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) red (d) green
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      border: 2px solid;
      margin: 10px;
      color: red;
    }
  10. 10.🌈 Which colour of light is strongest in rgb(108, 107, 237)? (a) red (b) blue (c) green
  11. 11.🧩 Which language changes the page live? (a) CSS (b) HTML (c) JavaScript
  12. 12.True or false: padding is the gap to other boxes. (a) True (b) False
  13. 13.🖌️ How big is the text, in px?
    h1 {
      font-size: 12px;
      background-color: orange;
      text-align: right;
      color: purple;
    }
  14. 14.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) white (d) red
  15. 15.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 270px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  16. 16.✍️ In color: blue; which part is the value? (a) ; (b) blue (c) color (d) :
  17. 17.🌈 In #cc0000 the red part is the hex number cc. What is it as a normal number?
  18. 18.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the viewport meta tag (d) the br tag
  19. 19.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) . (d) :
  20. 20.✍️ What value is given to background-color in this rule?
    li {
      font-style: italic;
      background-color: yellow;
    }
    (a) background-color (b) 10px (c) 8px (d) yellow
  21. 21.What does justify-content: flex-start do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
  22. 22.✍️ Which property is set to italic in this rule?
    p {
      font-style: italic;
      margin: 10px;
      width: 300px;
    }
    (a) color (b) italic (c) font-size (d) font-style
  23. 23.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
  24. 24.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
  25. 25.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
  26. 26.✍️ What value is given to color in this rule?
    h1 {
      margin: 10px;
      color: red;
      font-weight: bold;
    }
    (a) center (b) 20px (c) red (d) color
  27. 27.🌈 Which hex code is white? (a) #ff00ff (b) #ffffff (c) #00ffff (d) #00ff00
  28. 28.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) neither (d) the first one
  29. 29.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
  30. 30.What does background-color do? (a) centres a heading (b) makes the text bold (c) colours behind the text (d) sets the letter colour
  31. 31.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 290px;
      padding: 30px;
      border: 2px solid black;
      margin: 0px;
    }
  32. 32.🌈 In #220000 the red part is the hex number 22. What is it as a normal number?
  33. 33.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 20px;
      border: 4px solid black;
      margin: 0px;
    }
  34. 34.🌈 Which colour of light is strongest in rgb(3, 217, 21)? (a) red (b) green (c) blue
  35. 35.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  36. 36.🎯 Which CSS selector matches this element?
    <h2 class="star" id="main">Hello</h2>
    (a) #main (b) .main (c) .menu (d) #logo
  37. 37.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    #logo { color: purple; }
    h2 { color: yellow; }
    (a) blue (b) yellow (c) black (d) purple
  38. 38.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) align-items (c) justify-content (d) display: flex
  39. 39.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
  40. 40.✍️ What value is given to font-style in this rule?
    h2 {
      font-weight: bold;
      font-style: italic;
      background-color: yellow;
    }
    (a) font-style (b) italic (c) 20px (d) red

Answer key

  1. an id selector
  2. color
  3. yellow
  4. /*
  5. a solid or dotted edge
  6. False
  7. space inside the border
  8. red
  9. 3
  10. blue
  11. JavaScript
  12. False
  13. 12
  14. blue
  15. 70
  16. blue
  17. 204
  18. the viewport meta tag
  19. ;
  20. yellow
  21. packs boxes at the start
  22. font-style
  23. :
  24. 600px or narrower
  25. HTML
  26. red
  27. #ffffff
  28. the later one
  29. an id selector
  30. colours behind the text
  31. 354
  32. 34
  33. 108
  34. green
  35. an element selector
  36. #main
  37. purple
  38. display: flex
  39. CSS
  40. italic

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