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