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