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