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

Answer key

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

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