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

Answer key

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

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