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