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