Banner Image
Banner Image
Banner Image

CSS Clearfix Hack

Clearfix is one type of hack method to force the container’s(which has floating element inside) height based on the floated element. This is also know as Easy Clearing Hack. You can use this below code to avoid that layout issue arise by that floated element on all browsers.

[css]
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}

.clearfix {
display: inline-block;
}

html[xmlns] .clearfix {
display: block;
}

* html .clearfix {
height: 1%;
}
[/css]

Above CSS code containing the content: “.”; property. I have found that the period (or dot) specified in quotes has a nasty tendency to break certain layouts. By adding a literal dot after the .clearfix division (i.e., via the .clearfix:after selector), the clearfix hack creates a stumbling block for certain browsers. And not just for Internet Explorer — depending on the layout, even Firefox will choke a layout upon tripping on an :after-based pseudo-dot. The solution to this subtle design chaos? Replace the literal dot with a single blank space: “content: ” “; — this trick has proven successful so consistently that I now use it as the default property in every clearfix hack that I use.

Blog

27/10/2025
The Rise of Atlas Browser: Why More Users Are Switching to a Privacy-First Web
In today’s digital world, almost everything we do — from searching for information to online…
24/10/2025
Understanding WordPress: A Simple Guide for Beginners in 2025
If you’ve ever wondered how people build websites without knowing how to code, the answer…
15/10/2025
Building a Robust eCommerce Website with Magento: A Complete Guide by Sharesoft
In today’s fast-moving digital world, building a strong online presence is more than just having…
11/10/2025
Why Custom Shopify Website Development Is the Key to Building a Scalable eCommerce Brand
Introduction: The Rise of Shopify in Modern eCommerce In today’s fast-paced digital marketplace, where customer…

Stay Ahead in Digital Innovation

Looking for expert tips, industry insights, and strategies to boost your digital presence? Subscribe to Sharesoft Technology’s weekly LinkedIn newsletter!