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