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