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