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