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