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

Answer key

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

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