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