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