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