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