/* Container CSS */ .container { display: flex; flex-wrap: wrap; gap: 1rem; } /* Column CSS */ .column { flex: 1 1 300px; background-color: lightgray; padding: 1rem; }
Option D uses flexbox with wrapping and flexible basis, so columns take at least 300px and wrap to next line if needed, making it responsive.
Option D uses grid but fixes columns at 50%, which is not responsive without media queries.
Option D uses float, which is outdated and less flexible.
Option D stacks columns vertically always due to flex-direction: column.
<div class="custom-button" tabindex="0" role="button">Click me</div>
Option A adds tabindex="0" so the div is focusable by keyboard and role="button" so screen readers announce it as a button. Styling :focus helps users see focus.
Option A lacks keyboard focus and role, so keyboard users and screen readers miss it.
Option A lacks tabindex, so not keyboard focusable.
Option A uses tabindex="-1", which removes keyboard focus.
:is(.btn, .link) > span, which elements will it select?The :is(.btn, .link) groups selectors .btn and .link. The > span means select elements that are direct children of those elements.
Option C correctly describes this.
Option C reverses parent and child.
Option C misses the direct child requirement.
Option C describes a parent selector, which CSS does not support.
The transition property applies to background-color changes over 0.3 seconds with easing.
On hover, background-color changes from #007BFF (bright blue) to #0056b3 (darker blue) smoothly.
Text color and border radius do not change.
The grid has 2 columns and rows of 100px height.
The container height is 200px, so it fits exactly 2 rows.
2 columns × 2 rows = 4 items fully visible.
The 5th item is outside and hidden by overflow: hidden.
Practice
Solution
Step 1: Understand padding's role
Padding adds space inside an element, between its content and border, making buttons larger and easier to click.Step 2: Differentiate from margin
Margin adds space outside the element, not inside. Border and font-size do not add internal space.Final Answer:
padding -> Option CQuick Check:
Internal space in buttons = padding [OK]
- Confusing margin with padding
- Using border to add space
- Changing font-size to add space
primary?Solution
Step 1: Understand class selector syntax
To select elements with a class, use a dot (.) before the class name. Combining with element name is element.class.Step 2: Analyze each option
button.primary selects allbuttonelements with classprimary. .button primary is invalid syntax. #primary button selects buttons inside an element with idprimary. button#primary selects button with idprimary.Final Answer:
button.primary -> Option AQuick Check:
Class selector with element = element.class [OK]
- Using space instead of dot
- Confusing id (#) with class (.)
- Wrong order of selectors
button {
background-color: blue;
color: white;
}
button:hover {
background-color: green;
}Solution
Step 1: Understand the hover pseudo-class
The:hoverselector changes styles when the mouse is over the element.Step 2: Check the hover background-color
On hover, the background-color changes from blue to green as defined.Final Answer:
Green -> Option BQuick Check:
Hover changes background to green [OK]
- Ignoring :hover effect
- Confusing color with background-color
- Assuming no style change on hover
.card {
width: 300px;
margin: 0 auto 0 auto;
display: inline-block;
}
What is the main reason it fails?Solution
Step 1: Understand margin auto centering
Margin auto centers block elements with a fixed width horizontally.Step 2: Check display property effect
Settingdisplay: inline-blockmakes the element inline-level, somargin: 0 autodoes not center it.Final Answer:
'display: inline-block' prevents 'margin: 0 auto' from centering block elements -> Option AQuick Check:
Inline-block disables margin auto centering [OK]
- Using inline-block instead of block
- Wrong margin syntax
- Forgetting width units
Solution
Step 1: Identify layout needs
We want links spaced evenly and wrapping on small screens, so flexible layout and wrapping are needed.Step 2: Evaluate layout methods
Flexbox supports flexible spacing and wrapping withflex-wrap: wrapandjustify-content: space-between. Grid with fixed columns won't wrap well. Floats and inline-block are outdated and less flexible.Final Answer:
Flexbox with flex-wrap: wrap and justify-content: space-between -> Option DQuick Check:
Responsive spacing and wrapping = Flexbox wrap + space-between [OK]
- Using fixed widths preventing wrap
- Relying on floats for layout
- Ignoring flex-wrap property
