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

Answer key

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

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