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