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