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