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

Answer key

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

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