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

Answer key

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

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