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