Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What CSS property is commonly used to create a flexible layout that adjusts to different screen sizes?
The flexbox layout is created using the display: flex; property. It helps arrange items in rows or columns and adapts well to different screen sizes.
Click to reveal answer
beginner
How do you center content both vertically and horizontally using CSS Flexbox?
Use display: flex; on the container, then add justify-content: center; to center horizontally and align-items: center; to center vertically.
Click to reveal answer
intermediate
What CSS technique is best for creating a responsive navigation bar that stacks on small screens?
Use Flexbox with flex-wrap: wrap; and media queries to change the layout. On small screens, the navigation items can stack vertically for easier tapping.
Click to reveal answer
beginner
Which CSS property controls the space between grid items in a CSS Grid layout?
The gap property controls the space between rows and columns in a CSS Grid layout. It replaces older margin hacks and is easier to manage.
Click to reveal answer
beginner
How can you make a button visually accessible and easy to use on all devices?
Use sufficient color contrast, add padding for touch targets, use the button element for semantics, and include focus styles for keyboard users.
Click to reveal answer
Which CSS property is used to create a flexible box layout?
Aposition: absolute;
Bdisplay: flex;
Cfloat: left;
Ddisplay: block;
✗ Incorrect
The display: flex; property activates the flexbox layout, which helps arrange items flexibly.
What does the CSS property gap do in a grid layout?
ASets the background color
BAligns text
CChanges font size
DControls space between grid items
✗ Incorrect
gap sets the spacing between rows and columns in CSS Grid.
How do you center content vertically and horizontally with Flexbox?
Ajustify-content: center; align-items: center;
Btext-align: center;
Cmargin: auto;
Dfloat: center;
✗ Incorrect
Using justify-content and align-items both set to center centers flex items in both directions.
Which CSS feature helps make navigation menus stack on small screens?
AMedia queries
BText shadows
CBox shadows
DFont weights
✗ Incorrect
Media queries allow CSS to change styles based on screen size, enabling responsive stacking.
What is important for making buttons accessible?
ANo padding
BUsing only images
CHigh contrast and focus styles
DRemoving outlines
✗ Incorrect
High contrast and visible focus styles help all users, including keyboard users and those with vision impairments.
Explain how Flexbox helps create responsive layouts in common UI use cases.
Think about how items adjust and align inside a flexible box.
You got /5 concepts.
Describe how media queries work with CSS Grid or Flexbox to improve UI on small screens.
Consider how CSS changes when the screen is narrow.
You got /5 concepts.
Practice
(1/5)
1. Which CSS property is commonly used to add space inside a button to make it easier to click?
easy
A. font-size
B. margin
C. padding
D. border
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 C
Quick Check:
Internal space in buttons = padding [OK]
Hint: Padding adds inside space; margin adds outside space [OK]
Common Mistakes:
Confusing margin with padding
Using border to add space
Changing font-size to add space
2. Which CSS selector correctly targets all buttons with the class primary?
easy
A. button.primary
B. .button primary
C. #primary button
D. button#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 all button elements with class primary. .button primary is invalid syntax. #primary button selects buttons inside an element with id primary. button#primary selects button with id primary.
Final Answer:
button.primary -> Option A
Quick Check:
Class selector with element = element.class [OK]
Hint: Use dot before class name, no spaces for element.class [OK]
Common Mistakes:
Using space instead of dot
Confusing id (#) with class (.)
Wrong order of selectors
3. What will be the background color of the button when hovered, given this CSS?
A. 'display: inline-block' prevents 'margin: 0 auto' from centering block elements
B. Width is missing units
C. Margin syntax is incorrect
D. The card needs 'text-align: center' on parent
Solution
Step 1: Understand margin auto centering
Margin auto centers block elements with a fixed width horizontally.
Step 2: Check display property effect
Setting display: inline-block makes the element inline-level, so margin: 0 auto does not center it.
Final Answer:
'display: inline-block' prevents 'margin: 0 auto' from centering block elements -> Option A
Quick Check:
Inline-block disables margin auto centering [OK]
Hint: Use block display for margin auto centering [OK]
Common Mistakes:
Using inline-block instead of block
Wrong margin syntax
Forgetting width units
5. You want to create a responsive navigation bar with evenly spaced links that wrap on small screens. Which CSS layout method is best suited for this?
hard
A. Use inline-block links with fixed margins
B. Grid with fixed column widths
C. Float each link left with fixed widths
D. Flexbox with flex-wrap: wrap and justify-content: space-between
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 with flex-wrap: wrap and justify-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 D
Quick Check:
Responsive spacing and wrapping = Flexbox wrap + space-between [OK]
Hint: Use flex-wrap and justify-content for responsive nav bars [OK]