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

Answer key

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

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