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