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