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