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