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

Answer key

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

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