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