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