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