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

Answer key

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

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