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