Interview Question

What is float in CSS?

float is mainly for wrapping content around a floated box.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

The float property shifts a box to one side and allows inline content to wrap around it. • Floats were designed for content wrapping such as images in text. • They are removed from normal block flow but still affect surrounding line boxes. • Flexbox and Grid are usually better for page layout.

💡 Simple Example

.article-image { float: inline-start; margin-inline-end: 1rem; }

⚡ Quick Revision

float is mainly for wrapping content around a floated box.