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

Answer key

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

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