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