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