Skip to content

Clearfix

A clearfix makes a parent element wrap around its floated children again, so borders, backgrounds and the content that follows stay where you expect. The examples outline every parent with a dashed border and every floated box with a solid one, so you can see the helper at work.

1Two floated buttons

The parent wraps a float-start and a float-end button, so its dashed border surrounds both.

Dashed border: the .clearfix parent. It keeps its height even though both children float.

2With and without clearfix

Side by side comparison: without the helper the parent collapses to its padding and the float hangs out.

Without .clearfix

Float

With .clearfix

Float

3Media object

A floated avatar beside a short bio; the clearfix stops the next block from sliding up next to the image.

Isla Ibrahim

Isla Ibrahim

Project Manager, Valencia

This paragraph starts below the avatar, not beside it.

4Card header with floats

A title floated left and a status badge floated right inside a card header.

Takeaway Completed
Bread is baked every morning and pasta is rolled by hand in our kitchen.

5Toolbar

A floated button group and a floated search field share one toolbar row.

6Price list rows

Each list item floats the name left and the price right; clearfix keeps every row its own height.

  • Chocolate tart$8.00
  • Wood-fired pizza$19.00
  • Espresso martini$13.00
  • Seasonal soup$9.00

7Pull quote in an article

A quote floated to the end of the paragraph; the article wrapper is cleared so the next section starts below.

"Come hungry, leave happy"

Vegan, vegetarian and gluten-free dishes are marked clearly on every menu. Clear prices, honest advice and no surprises along the way. We have been feeding this neighbourhood for over a decade, and we still love it.

Children are always welcome, with a menu made just for them.

Next section starts on a clean line

8Comment with avatar

A comment row with a floated avatar and a floated time stamp.

Diego Okafor just now Diego Okafor

Book a table online in seconds, or call us for groups of eight or more.

9Responsive floats

float-md-start and float-md-end only float from the md breakpoint; below it the boxes stack.

Opening hours: 16:30
Melbourne

10Footer bar

Copyright floated left and social links floated right in a page footer.

© 2026 Yaraly Labs

11Invoice totals

The totals table floats to the end of an invoice; clearfix keeps the signature line below it.

Subtotal$595.00
Tax$41.65
Total$636.65

Thank you for your order #TX-3941.

12Floated thumbnail gallery

Several floated thumbnails wrap onto new lines; the gallery wrapper still has a real height.

Gallery photo 1Gallery photo 2Gallery photo 3Gallery photo 4Gallery photo 5Gallery photo 6

Caption text sits under the gallery.

13Form actions

Buttons floated to the end of a settings form.

14Floated tag list

Tags floated one after another; the clearfix parent grows with every wrapped line.

#design#release#tutorial#update#community#guide

15Notification item

An icon floated left, a time stamp floated right and the message in between.

1 days ago

We keep things simple, so you can focus on what matters to you.

16Pricing card label

A floated badge in the top corner of a pricing card body.

Pro plan

Popular

$70.47

per month

17Breadcrumb with action

A breadcrumb floated left and a button floated right above a page.

18Half-width stat tiles

Two floated tiles each half the width of the parent (w-50).

Visitors
38.2k
Orders
786

19Floated image in a card

A product image floated to the end of a card body with the description flowing around it.

Garden salad

Garden salad

Our terrace is open from spring to autumn, with heaters for cooler evenings.

20Sidebar and content

A classic two-column float layout: a floated nav box and a content box; clearfix closes the row.

The story of our wood-fired oven

We measure success by how many guests come back and tell their friends. Thousands of guests already trust us, and we work hard to keep it that way. Private dining rooms seat up to forty guests for birthdays and business dinners.