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

Answer key

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

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