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

Answer key

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

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