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