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