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