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