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