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

Answer key

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

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