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