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