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

Answer key

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

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