Interview Question

Difference between flexbox and grid?

Use Flexbox for one-axis arrangement and Grid for row-and-column layout.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

Flexbox is primarily one-dimensional, while Grid is two-dimensional. • Flexbox distributes items along a main axis and cross axis. • Grid defines rows and columns that items can occupy. • They can be combined; neither replaces the other.

💡 Simple Example

.page { display: grid; grid-template-columns: 16rem 1fr; } .actions { display: flex; gap: .5rem; }

⚡ Quick Revision

Use Flexbox for one-axis arrangement and Grid for row-and-column layout.