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