10 CSS Questions Test Your Skills

What does CSS stand for?
a) Creative Style Sheets
b) Computer Style Sheets
c) Cascading Style Sheets
d) Content Style Sheets
Answer: c) Cascading Style Sheets

Which CSS property is used to change the text color of an element?
a) background-color
b) font-color
c) text-color
d) color
Answer: d) color

What is the purpose of the “float” property in CSS?
a) It adds a shadow to an element.
b) It makes an element’s background transparent.
c) It allows an element to be moved to the right or left, and other elements will wrap around it.
d) It centers an element within its parent container.
Answer: c) It allows an element to be moved to the right or left, and other elements will wrap around it.

Which CSS selector selects all elements of a specific type on a web page?
a) .class
b) #id
c) *
d) element
Answer: d) element

What does the CSS property “margin” control?
a) The space between the element’s border and its content.
b) The space outside of the element’s border.
c) The font size of the element’s text.
d) The background color of the element.
Answer: b) The space outside of the element’s border.

Which CSS property is used to add a background color or image to an element?
a) background-color
b) color
c) font-family
d) border
Answer: a) background-color

What is the correct syntax to comment out a CSS rule?
a) // This is a comment
b)
c) /* This is a comment /
d) / This is a comment //
Answer: c) / This is a comment /

Which CSS property is used to change the style of an element’s border?
a) border-width
b) border-color
c) border-style
d) border-radius
Answer: c) border-style

How can you center an element horizontally in CSS?
a) text-align: center;
b) margin-left: auto; margin-right: auto;
c) align: center;
d) justify-content: center;
Answer: b) margin-left: auto; margin-right: auto;

What CSS property is used to control the spacing between lines of text within an element?
a) margin
b) padding
c) line-height
d) spacing
Answer: c) line-height