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

Answer key

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

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