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