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