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