What is a clearfix? Last Updated : 03 Aug, 2023 Comments Improve Suggest changes Like Article Like Report A clearfix is a way for an element to automatically clear or fix its elements so that it does not need to add additional markup. It is generally used in float layouts where elements are floated to be stacked horizontally. If the element is taller than the element containing it then use the overflow property of CSS by setting its value as auto in order to overcome & fix the problem. Example: From the below image, the logo is not fit into the div element. To fix this problem, there are two ways. The first is by increasing the height of the div block and the second by the use of clearfix CSS property. We will understand these concepts its implementation through the examples. Please refer to the CSS Float article to understand the floating concept in CSS. Example 1: In the code below, the problem is fixed without using the overflow property. HTML <!DOCTYPE html> <html> <head> <!-- CSS code to show the working of this property --> <style> div { border: 3px solid green; padding: 10px; height: 200px; text-align: justify; } img { float: right; } </style> </head> <body> <div> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png" alt="Pineapple" width="200" height="200"> GATE(Graduate Aptitude Test in Engineering) is one the most important and in-demand entrance exam for engineering graduates in our country. M.Tech. in Computer Science is one of the most demanding courses at prestigious institutes like IISCs and IITs. GATE(Graduate Aptitude Test in Engineering) is one of the ways to get into these top institutes. Every year around 10 Lakh candidates apply for GATE exam and very few of them manage to ace the exam with good score. So the competition is clearly very tough and simply preparing without any strategy will make it difficult to land you into IISCs and IITs. </div> </body> </html> Output: Example 2: In this code, the problem is fixed using the overflow property. HTML <!DOCTYPE html> <html> <head> <!-- CSS code to show the working of this property --> <style> div { border: 3px solid green; padding: 10px; text-align: justify; } img { float: right; } .gfg { overflow: auto; } </style> </head> <body> <div class="gfg"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png" alt="Pineapple" width="200" height="200"> GATE(Graduate Aptitude Test in Engineering) is one the most important and in-demand entrance exam for engineering graduates in our country. M.Tech. in Computer Science is one of the most demanding courses at prestigious institutes like IISCs and IITs. GATE(Graduate Aptitude Test in Engineering) is one of the ways to get into these top institutes. Every year around 10 Lakh candidates apply for GATE exam and very few of them manage to ace the exam with good score. So the competition is clearly very tough and simply preparing without any strategy will make it difficult to land you into IISCs and IITs. </div> </body> </html> Output: Comment More infoAdvertise with us K kundankumarjha Follow Improve Article Tags : Web Technologies CSS CSS-Misc Similar Reads CSS Preprocessor SASS Sass (Syntactically Awesome Style Sheets) is a CSS preprocessor that enhances standard CSS by introducing features like variables, nesting, imports, mixins, and inheritance, all while maintaining compatibility with all CSS versions.Key Features of Sass:Variables: Store reusable values such as colors 4 min read CSS Website Layout CSS website layout divides a webpage into multiple sections like header, navigation bar, content area, and footer, making it easier to organize content and build the site.1. Header SectionThe header is the top section of a webpage, typically containing the website's name or logo.html<html> 4 min read How to make div not larger than its contents using CSS? There are three ways to achieve this problem: By default case Using inline-block property Using fit-content property in width and height Default Case: In HTML div is by default fit to content inside it. The example goes like this: Example 1: html <!DOCTYPE html> <html lang = "en" 3 min read Building Tooltip using CSS A Tooltip provides users with additional information about an element when the mouse pointer hovers over it. For example, when a user hovers over a button labeled "GeeksForGeeks," additional information such as "A Computer Science Portal" can appear as a tooltip.Tooltip PositionsTooltips can be posi 7 min read How to Set Background Color Opacity without Affecting Text in CSS? Here are two approaches to set a background color with opacity in CSS without affecting the text.1. Using RGBA color valuesTo set the opacity only to the background color and not the text inside it we can use RGBA color values instead of the opacity property. Because using the opacity property can c 2 min read Transition shorthand with multiple properties in CSS? The transition shorthand in CSS allows specifying multiple properties for smooth transitions between different states or values. The transition property in CSS is used to create transitions in an element, enabling changes to occur smoothly over a specified duration. This article demonstrates how to 2 min read How to prevent line breaks in the list of items using CSS? The display:inline-block property is used to show an element in the inline-level block container. It converts the block of elements into an inline element. Use height and width property to set an inline element. The display property is used to prevent a line break of a list of items. Syntax: element 1 min read How to remove the space between inline-block elements? To remove space between inline-block elements in CSS, ensure no whitespace or line breaks exist in HTML between elements. Alternatively, set the font-size of the parent to 0 and reset for elements, or apply a negative margin to elements. This ensures elements align seamlessly without unwanted spacin 3 min read 6 Best CSS frameworks You should Know to design Attractive Websites If you want to speed up your website and development process, or want to add some classy designs to your website, then you're at the right place. Awesome new popups, speed, ultimate colors and themes are waiting for you. Front end development is the complete pack of creation and colors and have amaz 3 min read Space between two rows in a table using CSS The space between two rows in a table can be done using CSS border-spacing and border-collapse properties. The border-spacing property is used to set the spaces between cells of a table and border-collapse property is used to specify whether the border of the table is collapsed or not. The border-sp 1 min read Like