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

Answer key

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

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