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