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