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