473,761 Members | 7,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:le ft;">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:le ft;">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 5727
Florian Brucker wrote on 07 jun 2004 in
comp.infosystem s.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:le ft;">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:le ft;">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:lef t;">

--
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:le ft;">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:le ft;">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:le ft;">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.*********@co mcast.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
7223
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 style="border: 1ps solid red; float: left;">This is my 2nd float</div> <br clear="left">
1
2125
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 on the moon thumb to see the problem. In IE 5.2 on MacOS 10.2.6, the moon drops down below the list of thumbs. I'd like it to say to the right of the thumbs and be able to scroll right. In Netscape 7.2, the larger image of the moon stays to...
5
2297
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 deed. I'm trying to retain, somewhat, the layout of the original document. Below the deed are the signatures (on the right) and the names of witnesses (on the left), hence paired blocks of text.
7
3846
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 This is how it should work: (but it's fluke luck, not, apparently, design)
2
5719
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 http://dochawk.org/sample.html . This was made by stripping out the google ads from the regular pages. It validates as strict 4.01 at http://validator.w3.org. (The google ads drive it nuts!) The main (right) column is made with alternating left and right floats to...
7
17336
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 not resize at all. How come? HTML <div id="ads">
0
1396
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. (use a fixed-width font to view this!) Some short text. +-------+ | | +-------+
2
2440
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 float the dt left, and the dd right with fixed widths for each. This works fine in both IE and FF until I have a <br> elements within the dd elements. IE does not clear subsequent dt's, and they are not floated beneath the multiline dd element,...
9
5134
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 one problem surrounding this issue. I am trying to make a <div> block that contains a) a link b) an arrow or an image of an arrow c) another link d) another link floated off to the far right All of this must be on one horizontal line. The...
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.