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