
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Turning off Float using Clear Property of CSS
We can use CSS clear property to specify the side of the floated element which is to be cleared of flowing content.
Example
Let’s see an example of CSS clear property −
<!DOCTYPE html> <html> <head> <title>CSS Clear</title> <style type="text/css"> .clear { clear: left; } .yellow{ background-color: #FF8A00; } .red{ background-color: #F44336; } .green{ background-color: #4CAF50; } p { float: left; margin: 10px; padding: 10px; color:white; } </style></head> <body> <p class="red">Important Notice</p> <p class="clear red">Important Notice</p> <p class="yellow">Mediocre Notice</p> <p class="green">Ignorable Notice</p> </body> </html>
Output
This will produce the following output −
Example
Let’s see another example of CSS clear property −
<!DOCTYPE html> <html> <head> <title>CSS Clear</title> <style type="text/css"> p { float: left; margin: 10px; padding: 10px; color:white; background-color: #48C9B0; border: 4px solid #145A32; } p.noneFloat{ float: none; clear: both; color: #34495E; } </style></head> <body> <p>I am okay with shared space</p> <p class="noneFloat">I want a private space</p> <p>I am also okay with shared space</p> <p>Me too</p> </body> </html>
Output
This will produce the following output −
- Related Articles
- Align elements using the CSS float property
- Left and Right Alignment using the float Property in CSS
- Clear the float of an element with Bootstrap
- Using CSS z-index property
- Display Property Using in CSS
- HTML DOM Style clear Property
- Role of margin property with value inherit using CSS
- Role of margin property with value auto using CSS
- Cursor property of CSS
- Stacking Elements in Layers using z-index Property using CSS
- Center alignment using the margin property in CSS
- Aligning elements using the position property in CSS
- Float List Items to the right with CSS
- Usage of CSS perspective property
- Example of CSS Cursor Property

Advertisements