← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 883 · 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 sign starts a class selector? (a) # (b) & (c) @ (d) .
  2. 2.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the br tag (d) the hr tag
  3. 3.True or false: the border is the line round the box. (a) True (b) False
  4. 4.🎯 Which CSS selector matches this element?
    <h2 class="red" id="hero">Hello</h2>
    (a) li (b) #top (c) .red (d) #red
  5. 5.🌈 Which hex code is bright green? (a) #0000ff (b) #ffffff (c) #ff00ff (d) #00ff00
  6. 6.✍️ In color: blue; which part is the property? (a) ; (b) color (c) : (d) blue
  7. 7.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
  8. 8.Which of these does HTML do? (a) adds space around boxes (b) lays out the page (c) puts a picture on a page (d) counts down a timer
  9. 9.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
  10. 10.⚖️ What colour is the text of this element?
    <h1 class="box" id="main">Hi</h1>
    CSS:
    #main { color: red; }
    #main { color: green; }
    (a) green (b) yellow (c) white (d) red
  11. 11.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
  12. 12.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
  13. 13.🎯 Which element does the selector h1 style? (a) <div id="intro"> (b) <h1 class="star"> (c) <h2> (d) <li class="star">
  14. 14.🌈 Which hex code is magenta? (a) #ff0000 (b) #ff00ff (c) #0000ff (d) #000000
  15. 15.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
  16. 16.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  17. 17.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) exactly 100px (d) 800px or wider
  18. 18.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) align-items (d) gap
  19. 19.Which of these does HTML do? (a) changes the page live (b) makes a form box (c) adds space around boxes (d) counts down a timer
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: green; }
    (a) green (b) blue (c) yellow (d) red
  21. 21.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 16px;
      color: yellow;
      background-color: blue;
      text-align: left;
    }
    (a) on the left (b) on the right (c) in the middle
  22. 22.🎯 Which element does the selector #main style? (a) <div class="main"> (b) <div id="logo"> (c) <span class="box"> (d) <div id="main">
  23. 23.🌈 Which colour is #ff00ff? (a) bright green (b) magenta (c) blue (d) red
  24. 24.🌈 Which colour is #ffffff? (a) blue (b) magenta (c) red (d) white
  25. 25.🔍 Which is the odd one out? (a) lays out the page (b) changes the text size (c) changes the page live (d) rounds box corners
  26. 26.⚖️ What colour is the text of this element?
    <h1 class="big" id="logo">Hi</h1>
    CSS:
    h1 { color: red; }
    h1 { color: orange; }
    (a) orange (b) red (c) yellow (d) black
  27. 27.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
  28. 28.🖌️ How big is the text, in px?
    p {
      background-color: orange;
      font-size: 36px;
      color: red;
      text-align: right;
    }
  29. 29.🔍 Which is the odd one out? (a) sets colours and fonts (b) checks a quiz answer (c) shows a pop-up message (d) counts down a timer
  30. 30.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) red (d) white
  31. 31.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
  32. 32.True or false: HTML puts a picture on a page. (a) True (b) False
  33. 33.⚖️ What colour is the text of this element?
    <p class="box" id="intro">Hi</p>
    CSS:
    .box { color: red; }
    .box { color: black; }
    (a) yellow (b) black (c) white (d) red
  34. 34.🎯 What kind of selector is .big? (a) a class selector (b) an element selector (c) an id selector
  35. 35.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
  36. 36.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 50px;
      padding: 20px;
      border: 3px solid black;
      margin: 15px;
    }
  37. 37.🖌️ Which CSS property centres a heading? (a) background-color (b) font-size (c) text-align (d) font-family
  38. 38.True or false: HTML sets colours and fonts. (a) True (b) False
  39. 39.⚖️ What colour is the text of this element?
    <h1 class="red" id="main">Hi</h1>
    CSS:
    .red { color: red; }
    .red { color: blue; }
    (a) black (b) red (c) white (d) blue
  40. 40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 280px;
      padding: 5px;
      border: 5px solid black;
      margin: 15px;
    }

Answer key

  1. .
  2. the viewport meta tag
  3. True
  4. .red
  5. #00ff00
  6. color
  7. ;
  8. puts a picture on a page
  9. an element selector
  10. green
  11. CSS
  12. /*
  13. <h1 class="star">
  14. #ff00ff
  15. equal gaps, none at ends
  16. 10
  17. 800px or wider
  18. justify-content
  19. makes a form box
  20. green
  21. on the left
  22. <div id="main">
  23. magenta
  24. white
  25. changes the page live
  26. orange
  27. HTML
  28. 36
  29. sets colours and fonts
  30. blue
  31. an element selector
  32. True
  33. black
  34. a class selector
  35. packs boxes at the end
  36. 126
  37. text-align
  38. False
  39. blue
  40. 300

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