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

Answer key

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

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