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