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

Answer key

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

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