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

Answer key

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

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