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