Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

br clear="all" vs css solution

Tags:

css

I have a div that is float:left, and after the div is the rest of the page. In order to keep the rest of the page below the div, I must first place a

<br clear="all">

Q: How do I position the rest of the page below the floated div? I think that I need to wrap the rest of the page in a new div and float it as well. But I tend to stay away from floats as much as I can.

like image 712
Phillip Senn Avatar asked Aug 24 '11 18:08

Phillip Senn


People also ask

What is br clear all?

If you have text you want below the image, you can do this with <BR CLEAR=LEFT> or CLEAR=RIGHT to force scrolling down to a clear left or right margin, respectively. Using CLEAR=ALL will scroll down until both margins are clear.

Why clear both is used in CSS?

The “clear: both” means floating the elements are not allowed to float on both sides. It is used when no need of any element float on the left and right side as related to the specified element and wanted the next element only shown below.

What is clear CSS?

The clear CSS property sets whether an element must be moved below (cleared) floating elements that precede it. The clear property applies to floating and non-floating elements.


2 Answers

Create a class and insert into CSS:

br.cb { clear: both; }

Insert into HTML:

<br class="cb">

This made it past W3 markup and CSS validator.

like image 113
Alex Avatar answered Sep 18 '22 12:09

Alex


after the div you've floated. add the following code.

<div style='clear:both'></div>

then continue the rest of the page as usual.

like image 26
shahalpk Avatar answered Sep 21 '22 12:09

shahalpk