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

Answer key

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

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