Click here to get back home

Clearing floats without introducing a new line. How?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Clearing floats without introducing a new line. How? Andrey Tarasevich 08-18-2005
Posted by Andrey Tarasevich on August 18, 2005, 2:47 pm
Please log in for more thread options


Hello

Consider the following HTML code sketch

<div>
<img src="..." style="float: left">
<p>Paragraph text</p>
</div>
<hr>

If the <p> text is short, the <hr> element will be squeezed between the floating
image and the right edge of the viewport. I need the <hr> element to sit below
the bottom edge of the image. According to what I read on the Net, I can easily
achieve that by first clearing the floaters through a <br> element with a
'clear' attribute

<div>
<img src="..." style="float: left" width=... height=...>
<p>Some text</p>
<br clear="all">
</div>
<hr>

This works, but unfortunately the <br> element has an unwanted side effect - it
introduces a line break, i.e. an extra empty line. This is not noticeable when
the height of the <p> paragraph is small. However, once this height gets close
to the height of the image, the extra blank line starts to appear below the
image and above <hr> element. If the paragraph height is greater than the height
of the image the extra vertical space will exist under the bottom of the
paragraph.

This is not acceptable in my case. Hence the question: how can I issue a
directive to clear all floaters without taking up any vertical space? Is there a
"zero-height way" to do that?

Best regards,
Andrey



Posted by Andrey Tarasevich on August 18, 2005, 4:55 pm
Please log in for more thread options


Andrey Tarasevich wrote:
> ...

Problem solved. Instead of using <br> is should've just added 'clear' property
to <hr>.

--
Best regards,
Andrey

Similar ThreadsPosted
clearing only local floats November 11, 2006, 11:22 am
clearing out a May 3, 2005, 1:06 pm
selected clearing January 24, 2008, 11:36 am
Memory clearing and reload. January 23, 2005, 3:00 pm
Clearing floaters in Mozilla August 19, 2005, 6:03 pm
CSS Floats Images and IE (Help please!) September 4, 2005, 6:55 am
margins on cleared floats in Opera November 5, 2006, 11:34 am
How to keep this on one line? May 9, 2007, 4:39 pm
DIV without line breaks June 22, 2005, 4:37 pm
Button on the same line. July 20, 2005, 12:48 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap