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