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