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