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

Answer key

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

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