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