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