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