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

Answer key

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

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