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