← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 460 · 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.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 170px;
      padding: 15px;
      border: 5px solid black;
      margin: 15px;
    }
  2. 2.🔍 Which is the odd one out? (a) adds space around boxes (b) changes the text size (c) rounds box corners (d) makes a link
  3. 3.🖌️ Which CSS property makes the text bold? (a) color (b) text-align (c) font-weight (d) font-family
  4. 4.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  5. 5.🎯 Which CSS selector matches this element?
    <span class="box" id="top">Hello</span>
    (a) #box (b) .box (c) p (d) .star
  6. 6.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
  7. 7.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
  8. 8.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
  9. 9.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
  10. 10.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) magenta (c) red (d) cyan
  11. 11.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
  12. 12.🖌️ Which CSS property picks the font style? (a) color (b) text-align (c) background-color (d) font-family
  13. 13.🎯 What kind of selector is p? (a) a class selector (b) an element selector (c) an id selector
  14. 14.🖌️ Where does the text sit on its line?
    h1 {
      background-color: orange;
      font-size: 28px;
      text-align: center;
      color: black;
    }
    (a) on the right (b) on the left (c) in the middle
  15. 15.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    p { color: red; }
    p { color: blue; }
    (a) blue (b) red (c) purple (d) green
  16. 16.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) red (c) black (d) bright green
  17. 17.True or false: li is an element selector. (a) True (b) False
  18. 18.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) align-items (c) justify-content (d) display: flex
  19. 19.True or false: .menu is an element selector. (a) True (b) False
  20. 20.🌈 Which colour is #ff00ff? (a) white (b) black (c) yellow (d) magenta
  21. 21.True or false: #main is an id selector. (a) False (b) True
  22. 22.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      background-color: yellow;
      margin: 10px;
      font-style: italic;
    }
  23. 23.True or false: p is an element selector. (a) True (b) False
  24. 24.True or false: CSS reacts to a button click. (a) False (b) True
  25. 25.True or false: HTML gives the page structure. (a) False (b) True
  26. 26.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
  27. 27.✍️ What value is given to font-style in this rule?
    #top {
      font-style: italic;
      font-size: 20px;
      text-align: center;
      font-weight: bold;
    }
    (a) font-style (b) italic (c) red (d) 20px
  28. 28.True or false: padding is space inside the border. (a) False (b) True
  29. 29.🎯 Which CSS selector matches this element?
    <p class="star" id="logo">Hello</p>
    (a) .logo (b) .star (c) #end (d) #star
  30. 30.📦 In the box model, which part is space outside the border? (a) content (b) padding (c) margin (d) border
  31. 31.True or false: .star is an id selector. (a) False (b) True
  32. 32.Which of these does HTML do? (a) rounds box corners (b) makes headings and lists (c) shows a pop-up message (d) checks a quiz answer
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="star" id="main">Hi</h2>
    CSS:
    .star { color: purple; }
    #main { color: yellow; }
    (a) green (b) yellow (c) purple (d) orange
  34. 34.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the later one (d) the shorter one
  35. 35.📱 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
  36. 36.✍️ Which property is set to yellow in this rule?
    h2 {
      background-color: yellow;
      color: red;
    }
    (a) margin (b) background-color (c) padding (d) yellow
  37. 37.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
  38. 38.🎯 Which element does the selector h1 style? (a) <li class="menu"> (b) <h2> (c) <div id="top"> (d) <h1 class="menu">
  39. 39.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) changes the page live (d) puts a picture on a page
  40. 40.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >

Answer key

  1. 240
  2. makes a link
  3. font-weight
  4. Yes
  5. .box
  6. CSS
  7. fits every screen
  8. equal gaps, none at ends
  9. CSS
  10. magenta
  11. /*
  12. font-family
  13. an element selector
  14. in the middle
  15. blue
  16. bright green
  17. True
  18. justify-content
  19. False
  20. magenta
  21. True
  22. 3
  23. True
  24. False
  25. True
  26. packs boxes at the start
  27. italic
  28. True
  29. .star
  30. margin
  31. False
  32. makes headings and lists
  33. yellow
  34. the later one
  35. the viewport meta tag
  36. background-color
  37. 1
  38. <h1 class="menu">
  39. puts a picture on a page
  40. { }

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