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

Answer key

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

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