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

Answer key

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

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