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