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