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