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