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