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