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

Answer key

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

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