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

Answer key

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

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