← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 627 · 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 flexbox property picks row or column? (a) display: flex (b) flex-direction (c) align-items (d) gap
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    #hero { color: red; }
    h2 { color: green; }
    (a) black (b) green (c) white (d) red
  3. 3.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) 800px or wider (c) exactly 100px (d) turned off
  4. 4.True or false: the content is the gap to other boxes. (a) False (b) True
  5. 5.🎨 One CSS file can style how many pages? (a) many pages (b) only one word (c) no pages (d) only one image
  6. 6.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  7. 7.✍️ What value is given to font-size in this rule?
    p {
      font-size: 20px;
      padding: 8px;
      border: 2px solid;
    }
    (a) center (b) font-size (c) 20px (d) yellow
  8. 8.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: purple; }
    #intro { color: green; }
    (a) blue (b) green (c) purple (d) red
  9. 9.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) G (c) J (d) Z
  10. 10.True or false: JavaScript checks a quiz answer. (a) False (b) True
  11. 11.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) any number (d) 2
  12. 12.🎯 Which element does the selector h1 style? (a) <h1 class="red"> (b) <h2> (c) <div id="top"> (d) <li class="red">
  13. 13.⚖️ 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
  14. 14.True or false: CSS rounds box corners. (a) False (b) True
  15. 15.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
  16. 16.True or false: the border is the gap to other boxes. (a) True (b) False
  17. 17.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) content (d) margin
  18. 18.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
  19. 19.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
  20. 20.Which of these does CSS do? (a) makes headings and lists (b) puts a picture on a page (c) sets colours and fonts (d) gives the page structure
  21. 21.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
    (a) Yes (b) No
  22. 22.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) display: flex (c) gap (d) justify-content
  23. 23.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  24. 24.⚖️ What colour is the text of this element?
    <h1 class="menu" id="intro">Hi</h1>
    CSS:
    #intro { color: yellow; }
    #intro { color: white; }
    (a) green (b) white (c) purple (d) yellow
  25. 25.🎯 Which CSS selector matches this element?
    <div class="big" id="main">Hello</div>
    (a) #big (b) .red (c) div (d) #logo
  26. 26.What does background-color do? (a) centres a heading (b) makes letters bigger (c) makes the text bold (d) colours behind the text
  27. 27.✍️ What is the selector in this CSS rule?
    #top {
      padding: 8px;
      font-weight: bold;
      margin: 10px;
    }
    (a) bold (b) #top (c) li (d) padding
  28. 28.📦 In the box model, which part is the gap round content? (a) padding (b) margin (c) border (d) content
  29. 29.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
  30. 30.🌈 Which hex code is magenta? (a) #ffffff (b) #ff00ff (c) #00ff00 (d) #ff0000
  31. 31.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
  32. 32.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
  33. 33.✍️ Which property is set to red in this rule?
    h2 {
      font-size: 20px;
      color: red;
      background-color: yellow;
    }
    (a) text-align (b) font-size (c) red (d) color
  34. 34.True or false: CSS makes a link. (a) True (b) False
  35. 35.✍️ What is the selector in this CSS rule?
    #top {
      margin: 10px;
      color: red;
    }
    (a) margin (b) #top (c) red (d) li
  36. 36.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 30px;
      border: 2px solid black;
      margin: 0px;
    }
  37. 37.🖌️ How big is the text, in px?
    h1 {
      text-align: center;
      font-size: 28px;
      background-color: black;
      color: white;
    }
  38. 38.✍️ What value is given to width in this rule?
    #top {
      font-size: 20px;
      color: red;
      width: 300px;
    }
    (a) width (b) red (c) italic (d) 300px
  39. 39.✍️ What value is given to font-weight in this rule?
    li {
      font-weight: bold;
      width: 300px;
    }
    (a) 300px (b) 2px solid (c) bold (d) font-weight
  40. 40.🌈 Which hex code is blue? (a) #0000ff (b) #ffffff (c) #ff0000 (d) #ffff00

Answer key

  1. flex-direction
  2. red
  3. 800px or wider
  4. False
  5. many pages
  6. an id selector
  7. 20px
  8. green
  9. F
  10. True
  11. 1
  12. <h1 class="red">
  13. the later one
  14. True
  15. packs boxes at the end
  16. False
  17. margin
  18. an id selector
  19. CSS
  20. sets colours and fonts
  21. No
  22. justify-content
  23. an id selector
  24. white
  25. div
  26. colours behind the text
  27. #top
  28. padding
  29. flex-start
  30. #ff00ff
  31. 600px or narrower
  32. CSS
  33. color
  34. False
  35. #top
  36. 344
  37. 28
  38. 300px
  39. bold
  40. #0000ff

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