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