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

Answer key

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

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