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

Answer key

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

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