CSS Quiz
CSS (Cascading Style Sheets) controls how HTML looks: colours, spacing, fonts and layout. These questions check your knowledge of selectors, the box model, positioning, units and the way styles cascade and override each other.
What this quiz covers
- Selectors and specificity
- Box model: margin, border, padding
- Colours, fonts and units
- Positioning and layout basics
Study tip: When you miss a question about specificity or positioning, build a tiny example in a code editor and change one property at a time to see the effect.
Questions, answers and explanations
1. What is CSS?
- CSS is a style sheet language
- CSS separates presentation from content
- CSS is used to style HTML documents
- All of the mentioned
Answer: All of the mentioned
CSS is a stylesheet language used to style and layout HTML pages.
2. Which HTML tag is used to embed CSS in an HTML page?
- <css>
- <!DOCTYPE html>
- <script>
- <style>
Answer: <style>
The <style> tag is used for internal CSS.
3. Which CSS selector is used to specify a group of elements?
- tag
- id
- class
- both class and tag
Answer: class
The class selector can be applied to multiple elements.
4. Which technology introduced text, list, box, margin, border, color, and background properties?
- HTML
- PHP
- CSS
- Ajax
Answer: CSS
CSS provides styling properties such as margin, border, color, and background.
5. Which CSS framework is commonly used to create responsive websites?
- Django
- Rails
- Laravel
- Bootstrap
Answer: Bootstrap
Bootstrap is a popular CSS framework for responsive web design.
6. Which CSS selector is used to target a unique element?
- tag
- id
- class
- both class and tag
Answer: id
The id selector should uniquely identify a single element.
7. Which HTML tag defines an internal style sheet?
- <script>
- <link>
- <class>
- <style>
Answer: <style>
The <style> element contains internal CSS rules.
8. Which CSS property makes text bold?
- text-decoration: bold
- font-weight: bold
- font-style: bold
- text-align: bold
Answer: font-weight: bold
Use font-weight: bold to make text bold.
9. What happens with the CSS code h1 { color: "green"; }?
- Nothing happens
- An error occurs
- Heading becomes dark green
- Heading becomes green
Answer: Nothing happens
The color value should not be enclosed in quotes.
10. Which CSS property is used to make text italic?
- style
- font
- font-style
- @font-face
Answer: font-style
font-style: italic makes text italic.
11. What happens if a semicolon is missing between CSS properties?
- Color and underline work
- Only italic works
- All properties work
- Underline and italic work
Answer: Only italic works
Missing a semicolon can prevent previous declarations from being parsed correctly.
12. Which vendor prefix is used for WebKit browsers?
- -chrome
- -web
- -o-
- -webkit-
Answer: -webkit-
The correct vendor prefix is -webkit-.
13. Which is the correct syntax to link an external CSS file?
- <link rel="stylesheet" href="style.css">
- <link rel="stylesheet" src="style.css">
- <style rel="stylesheet" src="style.css">
- <style rel="stylesheet" link="style.css">
Answer: <link rel="stylesheet" href="style.css">
The href attribute specifies the stylesheet location.
14. Which was the first official W3C CSS Recommendation?
- CSS Level 2
- (X)HTML CSS
- CSS Level 1
- CSS Level 2.1
Answer: CSS Level 1
CSS Level 1 became the first official W3C recommendation.
15. Which function creates a linear gradient?
- gradient()
- linear-gradient()
- grayscale()
- image()
Answer: linear-gradient()
linear-gradient() creates smooth color transitions.
16. Which property sets an image as the border?
- background-image-source
- background-image
- border-image-source
- border-image
Answer: border-image-source
border-image-source specifies the image used for the border.
17. Which property defines all border properties in one declaration?
- border-collapse
- border-width
- padding
- border
Answer: border
The border shorthand sets width, style, and color together.
18. What are the valid ways to apply CSS?
- External CSS file
- Inline CSS
- Internal CSS in the head
- All of the mentioned
Answer: All of the mentioned
CSS can be applied externally, internally, or inline.
19. Which property sets the font size?
- font-size
- text-size
- text
- size
Answer: font-size
font-size controls the size of text.
20. Which of the following is NOT a property of the CSS box model?
- margin
- color
- width
- height
Answer: color
The CSS box model includes content, padding, border, and margin. Color is not part of the box model.