← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 847 · 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 tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the title tag (d) the hr tag
  2. 2.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 260px;
      padding: 10px;
      border: 2px solid black;
      margin: 20px;
    }
  3. 3.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 160px;
      padding: 5px;
      border: 4px solid black;
      margin: 15px;
    }
  4. 4.🔍 Which is the odd one out? (a) sets colours and fonts (b) shows a pop-up message (c) lays out the page (d) rounds box corners
  5. 5.⚖️ What colour is the text of this element?
    <p class="big" id="main">Hi</p>
    CSS:
    #main { color: green; }
    #main { color: purple; }
    (a) blue (b) white (c) green (d) purple
  6. 6.🧩 Which language reacts to a button click? (a) JavaScript (b) HTML (c) CSS
  7. 7.✍️ Which property is set to 2px solid in this rule?
    p {
      border: 2px solid;
      margin: 10px;
    }
    (a) font-style (b) border (c) 2px solid (d) width
  8. 8.🌈 Which hex code is yellow? (a) #ff0000 (b) #ffffff (c) #00ffff (d) #ffff00
  9. 9.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
  10. 10.🎯 Which sign starts an id selector? (a) & (b) @ (c) # (d) .
  11. 11.✍️ How does a CSS comment start? (a) // (b) /* (c) # (d) <!--
  12. 12.✍️ What value is given to text-align in this rule?
    .note {
      font-style: italic;
      text-align: center;
    }
    (a) center (b) yellow (c) text-align (d) 10px
  13. 13.✍️ Which property is set to italic in this rule?
    h2 {
      font-style: italic;
      width: 300px;
    }
    (a) font-size (b) color (c) italic (d) font-style
  14. 14.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-size: 20px;
      padding: 8px;
      margin: 10px;
    }
  15. 15.📦 In the box model, which part is the text or picture? (a) content (b) border (c) padding (d) margin
  16. 16.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 28px;
      }
    }
    (a) Yes (b) No
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      margin: 10px;
      font-weight: bold;
    }
  18. 18.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) blue (c) magenta (d) bright green
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 100px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  20. 20.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) : (d) -
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      font-style: italic;
    }
  22. 22.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
  23. 23.🌈 Which colour is #00ff00? (a) yellow (b) white (c) red (d) bright green
  24. 24.✍️ What value is given to background-color in this rule?
    li {
      margin: 10px;
      width: 300px;
      text-align: center;
      background-color: yellow;
    }
    (a) 8px (b) background-color (c) yellow (d) 10px
  25. 25.🎯 Which CSS selector matches this element?
    <h2 class="menu" id="main">Hello</h2>
    (a) li (b) #main (c) .note (d) .main
  26. 26.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 160px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  27. 27.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 210px;
      padding: 15px;
      border: 3px solid black;
      margin: 15px;
    }
  28. 28.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 6px;
      }
    }
  29. 29.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
  30. 30.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      border: 2px solid;
      margin: 10px;
      width: 300px;
      color: red;
    }
  32. 32.🌈 Which colour is #000000? (a) black (b) cyan (c) blue (d) white
  33. 33.✍️ What value is given to background-color in this rule?
    p {
      padding: 8px;
      background-color: yellow;
      margin: 10px;
    }
    (a) 10px (b) background-color (c) 8px (d) yellow
  34. 34.Which of these does CSS do? (a) reacts to a button click (b) shows a pop-up message (c) lays out the page (d) makes a link
  35. 35.True or false: CSS changes the text size. (a) True (b) False
  36. 36.✍️ Which property is set to red in this rule?
    h2 {
      border: 2px solid;
      color: red;
    }
    (a) red (b) color (c) font-size (d) text-align
  37. 37.True or false: #end is an id selector. (a) False (b) True
  38. 38.True or false: CSS makes a link. (a) False (b) True
  39. 39.🎯 Which element does the selector h1 style? (a) <h1 class="box"> (b) <div id="logo"> (c) <li class="box"> (d) <h2>
  40. 40.🎯 Which CSS selector matches this element?
    <div class="star" id="end">Hello</div>
    (a) #star (b) #end (c) .end (d) span

Answer key

  1. the viewport meta tag
  2. 284
  3. 208
  4. shows a pop-up message
  5. purple
  6. JavaScript
  7. border
  8. #ffff00
  9. { }
  10. #
  11. /*
  12. center
  13. font-style
  14. 3
  15. content
  16. No
  17. 2
  18. bright green
  19. 20
  20. :
  21. 1
  22. 600px or narrower
  23. bright green
  24. yellow
  25. #main
  26. 60
  27. 246
  28. 12
  29. flex-end
  30. color
  31. 4
  32. black
  33. yellow
  34. lays out the page
  35. True
  36. color
  37. True
  38. False
  39. <h1 class="box">
  40. #end

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