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