473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

float/clear problem

Hi!

I've got a problem with float & clear. Take this example code:

<div style=" width:100px; height:100px; background-color:#FF0000;
float:left; margin:10px;"></div>
<span style="clear:left;">This is some text</span>

In Mozilla 1.6 the span still floats around the image on the left side
(as if there wasn't a "clear" option). When I use

<h1 style="clear:left;">This is some text</h1>

instead of the span it works as it should (using the h1 without the
clear-option gives the right result, too, the heading floats around the
image on the left side).

Is this behaviour correct (according to the specification)? If yes, how
can I achieve the desired result (the span acting like there was a <br
clear="all"> infront of it)?
Thanks for any hints,
Florian
Jul 20 '05 #1
4 5704
Florian Brucker wrote on 07 jun 2004 in
comp.infosystems.www.authoring.stylesheets:
I've got a problem with float & clear. Take this example code:

<div style=" width:100px; height:100px; background-color:#FF0000;
float:left; margin:10px;"></div>
<span style="clear:left;">This is some text</span>

In Mozilla 1.6 the span still floats around the image on the left side
(as if there wasn't a "clear" option). When I use

<h1 style="clear:left;">This is some text</h1>

instead of the span it works as it should (using the h1 without the
clear-option gives the right result, too, the heading floats around the
image on the left side).

Is this behaviour correct (according to the specification)? If yes, how
can I achieve the desired result (the span acting like there was a <br
clear="all"> infront of it)?


Floating an INLINE element is unreasonable, You should use a floating
block element.

Clearing a float has the same idea: an inline element cannot get clear of
a block.

so try:

<span style="display:block;clear:left;">

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

"Florian Brucker" <to**@torfbold.com> wrote in message
news:2i************@uni-berlin.de...
Hi!

I've got a problem with float & clear. Take this example code:

<div style=" width:100px; height:100px; background-color:#FF0000;
float:left; margin:10px;"></div>
<span style="clear:left;">This is some text</span>

In Mozilla 1.6 the span still floats around the image on the left side
(as if there wasn't a "clear" option). When I use

<h1 style="clear:left;">This is some text</h1>

instead of the span it works as it should (using the h1 without the
clear-option gives the right result, too, the heading floats around the
image on the left side).

Is this behaviour correct (according to the specification)?
I think so. When you have both blocks and freestanding inlines inside a
block, for formatting purposes the user agent essentially wraps the inlines
in their own anonymous blocks. So your code is treated as:

<div style=" width:100px; height:100px; background-color:#FF0000;
float:left; margin:10px;"></div>
<div><span style="clear:left;">This is some text</span></div>

I think the "clear: left;" is acting only within the context of the span's
enclosing anonymous div. Since, in that div, it's not preceded by anything
that floats, it has no effect.
If yes, how
can I achieve the desired result (the span acting like there was a <br
clear="all"> infront of it)?


So the solution is to put the span inside an explicit div, and give the div
the "clear: left; " style.

I would suggest that it's good coding practice in general for a block not to
have both blocks and inlines as immediate children.

Jul 20 '05 #3

"Harlan Messinger" <h.*********@comcast.net> wrote in message
news:2i************@uni-berlin.de...

I think so. When you have both blocks and freestanding inlines inside a
block, for formatting purposes the user agent essentially wraps the inlines in their own anonymous blocks. So your code is treated as:


I forgot to give you the reference:
http://www.w3.org/TR/REC-CSS2/visure...us-block-level

Jul 20 '05 #4
Okay, thanks you both! This leads right to my next question :)

(Which I will post in another thread as it's something different).

Florian
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Urs Martini | last post by:
Hi! I experienced some problems using IE 6 and some kind of css like this: .... text above ... <div style="border: 1ps solid blue; float: left;">This is my 1st float</div> <div...
1
by: Robert | last post by:
I created two pages. One using CSS and the other using a table. I'd like the css version to work like the table version. The problem arises when the full image doesn't fit in the window. Click...
5
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/BeallSprings/WC.Deed%20GG.116-17.html using the CSS at http://pages.prodigy.net/chris_beall/BeallSprings/BSstyle.css The page is a transcript of a...
7
by: Will Hartung | last post by:
Hi all... I'm working on a site that is show up a strange float bug (shocking I know) using Mozilla 1.7. You can see the problem here: http://www.marieosmond.com/Catalog1.aspx?coll=Y&page=2...
2
by: Dr. Richard E. Hawkins | last post by:
I've googled around, and asked everyone I know, but I still can't find any reference to anyone else having faced this particular IE bug with floats. I've put a page at...
7
by: Gnolen | last post by:
Hi, I have a problem with float in firefox/mozilla, the 'ads'-div doesn't resize on the height with the 'ads_left' and 'ads_right'. In IE there is no problem but in FF there is. The 'ads'-div do...
0
by: Paul E Collins | last post by:
Hello. I want to display a number of individual blocks of text. Each block has an associated image, which should be displayed on the right and aligned with the top of its block of text, i.e....
2
by: krsgoss | last post by:
I'm trying to do a two column "form" layout based on article here: http://www.alistapart.com/stories/practicalcss/ The idea is to have a label, and a value using definition list markup. I...
9
panachepad
by: panachepad | last post by:
I arrived here from a websearch that found this thread from your archives: http://www.thescripts.com/forum/thread97805.html It helped me to understand that I am on the right track, but I still have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.