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