← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 400 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ In color: blue; which part is the value? (a) color (b) : (c) ; (d) blue
  2. 2.✍️ What is the selector in this CSS rule?
    body {
      background-color: yellow;
      border: 2px solid;
      padding: 8px;
      font-style: italic;
    }
    (a) background-color (b) body (c) .box (d) 2px solid
  3. 3.✍️ What value is given to padding in this rule?
    .box {
      text-align: center;
      padding: 8px;
    }
    (a) padding (b) bold (c) 2px solid (d) 8px
  4. 4.✍️ What is the selector in this CSS rule?
    .box {
      font-size: 20px;
      color: red;
    }
    (a) .box (b) font-size (c) h2 (d) red
  5. 5.✍️ Which property is set to center in this rule?
    h1 {
      text-align: center;
      width: 300px;
      font-weight: bold;
      background-color: yellow;
    }
    (a) center (b) background-color (c) margin (d) text-align
  6. 6.✍️ What is the selector in this CSS rule?
    .box {
      background-color: yellow;
      font-style: italic;
      font-size: 20px;
      margin: 10px;
    }
    (a) italic (b) h2 (c) background-color (d) .box
  7. 7.✍️ Which property is set to 10px in this rule?
    body {
      background-color: yellow;
      color: red;
      margin: 10px;
    }
    (a) font-weight (b) 10px (c) margin (d) padding
  8. 8.✍️ What value is given to width in this rule?
    body {
      width: 300px;
      text-align: center;
    }
    (a) red (b) italic (c) width (d) 300px
  9. 9.✍️ How does a CSS comment start? (a) # (b) // (c) <!-- (d) /*
  10. 10.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) color (d) :
  11. 11.✍️ What value is given to background-color in this rule?
    body {
      padding: 8px;
      font-style: italic;
      font-size: 20px;
      background-color: yellow;
    }
    (a) background-color (b) 8px (c) 10px (d) yellow
  12. 12.✍️ What value is given to font-style in this rule?
    h1 {
      font-style: italic;
      font-size: 20px;
      color: red;
    }
    (a) italic (b) red (c) font-style (d) 20px
  13. 13.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      margin: 10px;
      background-color: yellow;
      border: 2px solid;
    }
  14. 14.✍️ What is the selector in this CSS rule?
    #top {
      background-color: yellow;
      color: red;
      font-style: italic;
    }
    (a) background-color (b) #top (c) red (d) li
  15. 15.✍️ Which property is set to yellow in this rule?
    .box {
      border: 2px solid;
      margin: 10px;
      background-color: yellow;
    }
    (a) margin (b) padding (c) background-color (d) yellow
  16. 16.✍️ Which property is set to yellow in this rule?
    #top {
      font-style: italic;
      background-color: yellow;
    }
    (a) padding (b) background-color (c) yellow (d) margin
  17. 17.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) : (d) ;
  18. 18.✍️ What value is given to color in this rule?
    .box {
      color: red;
      font-weight: bold;
    }
    (a) 20px (b) color (c) center (d) red
  19. 19.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      color: red;
      background-color: yellow;
    }
  21. 21.✍️ What value is given to font-style in this rule?
    .box {
      text-align: center;
      color: red;
      border: 2px solid;
      font-style: italic;
    }
    (a) font-style (b) red (c) 20px (d) italic
  22. 22.✍️ What is the selector in this CSS rule?
    h2 {
      width: 300px;
      font-size: 20px;
    }
    (a) 20px (b) width (c) h1 (d) h2
  23. 23.✍️ Which property is set to 2px solid in this rule?
    h1 {
      border: 2px solid;
      padding: 8px;
    }
    (a) font-style (b) 2px solid (c) border (d) width
  24. 24.✍️ Which property is set to 8px in this rule?
    p {
      color: red;
      padding: 8px;
    }
    (a) font-weight (b) 8px (c) border (d) padding
  25. 25.✍️ What value is given to text-align in this rule?
    h2 {
      text-align: center;
      color: red;
    }
    (a) yellow (b) 10px (c) center (d) text-align
  26. 26.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      text-align: center;
      color: red;
    }
  27. 27.✍️ What is the selector in this CSS rule?
    .note {
      background-color: yellow;
      padding: 8px;
    }
    (a) 8px (b) #top (c) background-color (d) .note
  28. 28.✍️ Which property is set to red in this rule?
    li {
      color: red;
      text-align: center;
      padding: 8px;
      margin: 10px;
    }
    (a) text-align (b) red (c) color (d) font-size
  29. 29.✍️ Which property is set to bold in this rule?
    #top {
      font-size: 20px;
      font-style: italic;
      font-weight: bold;
    }
    (a) font-weight (b) width (c) bold (d) border
  30. 30.✍️ Which property is set to 8px in this rule?
    .box {
      padding: 8px;
      font-weight: bold;
    }
    (a) 8px (b) font-weight (c) padding (d) border
  31. 31.✍️ What value is given to font-size in this rule?
    h2 {
      font-size: 20px;
      width: 300px;
      font-style: italic;
    }
    (a) center (b) font-size (c) 20px (d) yellow
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      background-color: yellow;
    }
  33. 33.✍️ What is the selector in this CSS rule?
    p {
      font-size: 20px;
      width: 300px;
      font-weight: bold;
    }
    (a) p (b) .note (c) font-size (d) 300px
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      text-align: center;
      padding: 8px;
      background-color: yellow;
    }
  35. 35.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      padding: 8px;
      margin: 10px;
      font-style: italic;
    }
  37. 37.✍️ What value is given to font-weight in this rule?
    .box {
      color: red;
      border: 2px solid;
      font-weight: bold;
    }
    (a) font-weight (b) 2px solid (c) bold (d) 300px
  38. 38.✍️ What is the selector in this CSS rule?
    body {
      padding: 8px;
      font-size: 20px;
    }
    (a) padding (b) 20px (c) body (d) .box
  39. 39.✍️ Which property is set to red in this rule?
    .note {
      font-weight: bold;
      border: 2px solid;
      color: red;
    }
    (a) red (b) font-size (c) color (d) text-align
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      color: red;
      background-color: yellow;
    }

Answer key

  1. blue
  2. body
  3. 8px
  4. .box
  5. text-align
  6. .box
  7. margin
  8. 300px
  9. /*
  10. color
  11. yellow
  12. italic
  13. 3
  14. #top
  15. background-color
  16. background-color
  17. ;
  18. red
  19. { }
  20. 2
  21. italic
  22. h2
  23. border
  24. padding
  25. center
  26. 2
  27. .note
  28. color
  29. font-weight
  30. padding
  31. 20px
  32. 1
  33. p
  34. 3
  35. :
  36. 3
  37. bold
  38. body
  39. color
  40. 2

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