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