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