Welcome CSS (Cascading Style Sheets) quiz. This CSS quiz consists of 30+ multiple-choice questions to put your skills to the test. Each question comes with detailed explanations to help you learn and improve your CSS expertise. Let's dive in and see how well you know your styles!
1. What is the full form of the acronym CSS?
a. Creative Style Sheets
b. Cascading Style Sheets
c. Colorful Style Sheets
d. Computer Style Sheets
2. Which HTML attribute is used to define inline styles?
a. class
b. font
c. style
d. styles
3. How do you insert a comment in a CSS file?
a. // this is a comment //
b. <!-- this is a comment -->
c. /* this is a comment */
d. ' this is a comment '
4. Which property is used to change the background color?
a. bgcolor
b. color
c. background-color
d. bg-color
5. How do you select an element with the id "demo"?
a. .demo
b. #demo
c. *demo
d. $demo
6. How do you select an element with the class "my-class" in CSS?
a) #my-class
b) .my-class
c) my-class
d) <my-class>
7. Which property is used to change the text color of an element?
a) color
b) font-color
c) text-color
d) text
8. Which property is used to change the font of an element?
a. font-style
b. text-font
c. font-family
d. text-family
9. Which property is used to change the text size of an element?
a. text-size
b. font-size
c. text-style
d. size
10. How do you make each word in a text start with a capital letter?
a. text-transform:capitalize
b. text-transform:uppercase
c. text-transform:lowercase
d. text-style:capitalize
11. Which property is used to add a background image?
a. background-color
b. color
c. background-image
d. image-background
12. What is the default position value of an element in CSS?
a) static
b) relative
c) absolute
d) fixed
13. Which property is used to add space between the content and the border of an element?
a) margin
b) padding
c) border
d) spacing
14. What is the purpose of the z-index property in CSS?
a) It controls the order of flex items.
b) It sets the spacing between elements.
c) It adjusts the opacity of an element.
d) It controls the stacking order of elements.
15. Which property is used to create rounded corners for an element?
a) border-style
b) border-radius
c) border-width
d) border-color
16. What is the purpose of the display: none; property in CSS?
a) It hides an element without affecting the layout.
b) It removes the element from the DOM.
c) It creates an invisible element that still occupies space.
d) It applies an invisible background color to the element.
17. How do you select all <a> elements within an <div> element using CSS?
a) div + a
b) a > div
c) div a
d) a div
18. What is the purpose of the float property in CSS?
a) It controls the vertical alignment of an element.
b) It allows text to wrap around an element.
c) It animates an element's position.
d) It applies a blur effect to an element.
19. Which CSS property is used to change the style of the mouse cursor when hovering over an element?
a) cursor-style
b) mouse-cursor
c) cursor-type
d) cursor
20. How do you apply a shadow effect to an element in CSS?
a) box-shadow: 2px 2px gray;
b) shadow: 2px 2px gray;
c) text-shadow: 2px 2px gray;
d) element-shadow: 2px 2px gray;
21. What is the purpose of the transform property in CSS?
a) It changes the position of an element.
b) It applies a 3D effect to an element.
c) It rotates and scales an element.
d) It animates an element's size.
22. How do you change the text alignment to the center for an element in CSS?
a) align: center;
b) text-align: center;
c) align-text: center;
d) text: center;
23. What is the purpose of the @media rule in CSS?
a) It defines custom fonts for different screen sizes.
b) It applies styles based on user interactions.
c) It allows the use of variables in CSS.
d) It applies styles based on screen size and other media features.
24. Which CSS property is used to control the spacing between lines of text?
a) letter-spacing
b) text-spacing
c) line-height
d) text-line-height
25. What is the purpose of the opacity property in CSS?
a) It changes the transparency of an element.
b) It creates a blur effect on an element.
c) It adjusts the brightness of an element.
d) It sets the reflection of an element.
26. How do you add a smooth transition effect to an element in CSS?
a) transition: smooth;
b) transition: 1s ease;
c) animate: smooth;
d) animate: 1s ease;
27. Which CSS property is used to create a fixed-position element that remains in the same position even when scrolling?
a) position: fixed;
b) position: absolute;
c) position: static;
d) position: relative;
28. What is the purpose of the overflow property in CSS?
a) It controls the visibility of an element's content.
b) It sets the shadow effect of an element.
c) It adjusts the space between elements.
d) It creates a gradient background for an element.
29. How do you set the width of an element to be 50% of its parent's width in CSS?
a) width: 50;
b) width: 50px;
c) width: 50%;
d) width: 0.5;
30. What is the purpose of the flexbox layout in CSS?
a) It creates a grid-like layout for elements.
b) It arranges elements in a single row or column.
c) It aligns elements based on their baseline.
d) It creates complex 3D layouts.
31. What color will the text be with the following CSS?
p {
color: blue;
}
p {
color: red;
}
a) Blue
b) Red
c) Both
d) None
32. What does the following CSS selector select?
div p {
}
a) All p elements
b) All div elements
c) All p elements inside div elements
d) All div elements inside p elements
33. How do you make every element bold in CSS?
a)
p {
font-style: bold;
}
b)
p {
font-weight: bold;
}
c)
p {
text-weight: bold;
}
d) None of the above
Conclusion
Congratulations on completing the CSS quiz! We hope you enjoyed the challenge and learned some new CSS concepts along the way. CSS is a powerful styling language that allows you to create visually stunning web pages and user interfaces.
Keep practicing and experimenting to become a CSS master! Happy coding!
Comments
Post a Comment
Leave Comment