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