Understanding Media Queries
Which of the following best describes the main purpose of CSS media queries?
- To apply specific styles based on device characteristics such as screen size
- To add custom fonts to a webpage
- To reset browser default styles
- To create shadows around elements
- To increase the load speed of CSS files
Setting Breakpoints
In responsive design, what does a CSS breakpoint typically represent?
- A specific screen size where the layout changes
- A line of code that stops the browser from rendering
- A comment added to explain CSS code
- An error in the stylesheet
- A variable controlling color themes
Mobile-First Design
What is the key idea behind the mobile-first approach in CSS?
- Start designing for small screens, then add styles for larger screens
- Begin with desktop styles and remove features for smaller devices
- Use only pixel values for sizing elements
- Apply styles based on print media
- Avoid the use of any relative units
Box Model Basics
Which of these correctly represents the four layers of the CSS box model, from innermost to outermost?
- Content, Padding, Border, Margin
- Padding, Border, Margin, Content
- Border, Margin, Padding, Content
- Content, Margin, Border, Padding
- Margin, Border, Content, Padding
Horizontal Centering
What combination is used to horizontally center a block-level element with a specified width in CSS?
- margin-left: auto; margin-right: auto;
- float: left; position: fixed;
- display: inline-block; margin: 0;
- align-items: center; justify-content: flex-end;
- padding: 10px; text-align: right;
Vertically Align Text
Which CSS property can help vertically center text within a fixed-height container without using flexbox?
- line-height
- font-style
- text-indent
- word-spacing
- float
Sticky Header Technique
Which CSS value will keep a header element fixed at the top of its container as the user scrolls?
- position: sticky;
- position: absolute;
- position: float;
- visibility: visible;
- z-index: 100;
Responsive Typography
What is one benefit of using rem units for font sizing in responsive design?
- They are relative to the root element and ensure consistent scaling
- They prevent font smoothing issues
- They automatically load custom fonts
- They reference the screen resolution directly
- They are always smaller than em units
Flexbox Centering
Which combination of flexbox properties should you apply to a container to center its content both vertically and horizontally?
- display: flex; justify-content: center; align-items: center;
- display: block; text-align: center;
- float: right; top: 50%;
- display: grid; grid-gap: 0;
- margin: auto; width: 100%;
Optimizing CSS Performance
Which of the following is a best practice for optimizing CSS performance?
- Minimize the number of CSS rules and selectors
- Use inline styles for every element
- Avoid using classes and stick to element selectors only
- Set !important on all rules
- Duplicate styles across multiple stylesheets