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