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