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

Answer key

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

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