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

Answer key

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

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