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