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