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

Answer key

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

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