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

Answer key

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

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