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

Answer key

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

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