Explore essential CSS techniques to enhance your web development workflow and create responsive, visually appealing websites. Master flexible layouts, custom styles, and smooth interactions.
Which of the following allows you to store reusable values in CSS for easier maintainability across your stylesheets?
Explanation: CSS variables enable you to define reusable values, making updates easier and reducing repetition. ID selectors uniquely identify elements but are not for reusable values. Media queries are used for responsive design, and z-index controls stacking order, not value storage.
When creating a flexible and responsive one-dimensional layout for a set of items, which CSS property should you apply to the container?
Explanation: Applying display: flex to a container enables the Flexbox layout, which aligns and distributes child items efficiently. Position: absolute removes elements from normal flow, float: left is an older layout technique, and overflow: scroll deals with scrollbars, not layout.
Which CSS selector enables you to target and style every odd numbered item in a list?
Explanation: The :nth-child(odd) selector targets every odd element among siblings, commonly used for alternating styles. :first-child selects only the first element, :last-of-type selects the last of its type, and :visited applies to links that have been visited.
What is the primary purpose of using media queries in CSS?
Explanation: Media queries allow styles to change based on screen properties, making designs responsive. Resetting browser styles typically uses a CSS reset, embedding fonts involves @font-face or third-party links, and drop shadows use the box-shadow property.
Which of the following CSS features smooths changes in property values, such as color or size, when hovering over an element?
Explanation: CSS transitions enable smooth visual changes when a property updates, such as on hover. Float is used for positioning, overflow manages content that exceeds a box, and clearfix is an old technique to clear floats, not to animate changes.