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

Answer key

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

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