473,770 Members | 5,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

float:right goes to next line

Hi,
I am trying to put text on left and right side of the page and used:
<div>
<span>blah blah</span>
<span style="float:ri ght">blah blah</span>
</div>
The 2nd text does go to the right but the next line. What am I doing
wrong?

TIA.

Jan 12 '07
22 51554
On 2007-01-14, Gus Richter <gu********@net scape.netwrote:
Gus Richter wrote:
><http://www.w3.org/TR/CSS21/visuren.html#q1 5>
9.4.1 Block formatting contexts
Floats establish new block formatting contexts.
In a block formatting context, boxes are laid out one after the other,
vertically, beginning at the top of a containing block.

Yes, 7. (anonymous text after the floated SPAN) aligns to the top of the
line box, but 6. (floated SPAN), in a block context and following 5.
(the in-flow SPAN, essentially a block now), causes 6. (floated SPAN) to
be laid out vertically, on a new line, below 5. and that's why I said
that even in Strict Mode, I believe Fx and IE are correct and Opera is
wrong.

OK, I see my mistake now. I kept skipping over:

"In a block formatting context, boxes are laid out one after the other,
vertically, _beginning at the top of a containing block_."

*You were right and I was wrong*. I agree with you now in that Opera is
right and Fx and IE are wrong.
All the same, what normally happens when it's time to start a new block
box is the new block box starts below the old one.

But if the new block box is a floating block, it's aligned with the top
of the current line in the existing block box. Then the current line has
to be reformatted around the float (which may mean repositioning the
float if the line breaks-- that's why the rule is annoying).
3. The principal block box (the div container) contains a floated SPAN
which establishes a new block formatting _context_.

Which somewhere in the thread you correctly point out is regarding the
"content" and not the float itself. I'll have to check on how I
countered that.
Yes.

In passing note that "block formatting context" is not the same as
"block box". All block formatting contexts are also block boxes, but not
all block boxes are block formatting contexts.
I hope that I've not gone in circles.
If you have you haven't been the only one :)
I have to walk away from this for a day or two and then look at it
again. Thank you, because this exchange has been very helpful and
informative (I hope). Thought provoking for sure.
Certainly.
Jan 14 '07 #21
Just to be absolutelly correct, Firefox do it this way:

S1 S2
LF
Firefox always does the first of the two alternatives, regardless
of the container box width.
Jan 14 '07 #22
In article <sv************ *************** ***@golden.net> ,
Gus Richter <gu********@net scape.netwrote:
Eric Lindsay wrote:
http://www.ericlindsay.com/palmtop/palmnote.htm
After reading your fine explanation, I think I am still confused as to
why different browsers made different decisions about this.

Thank you for the kind words. I feared the worst and therefore hesitated
to comment in this newsgroup. I have looked at your page and believe it
to be an actual live example of the problem.
I have hesitated to use anything like my example in most of my pages
because I did not understand why I was having the positioning problems I
encountered. This discussion is the first that gave me any appreciation
of what was happening. So I can finally get back to experimenting with
that page. Thank you very much.
>
If you have followed the discussion, you will have noticed that I was
unsure of my reasoning and in fact am still unsure of my sudden reversed
position.
Yes. Like you, I have changed my mind several times about what was the
intended effect of the CSS specification, and which browser was right. I
have returned to my first view, that Opera and Safari have it right, and
IE and Firefox have it wrong.
Oh, and I suppose that the different browser developers also had
problems interpreting the muddled morass on the subject?
On the side of dealing with it, it seems unlikely that IE and Firefox
will change to the Opera and Safari view. Especially when coding it
their way may be easier. So pragmatically, from now on I will put the
right floated LI element as the first LI element in a UL.

It does seem to me this would make CMS code a little cleaner, when I get
around to writing it. It also means that instead of styling the LI
pointing to the current location by means of an ID or CLASS, I can
remove the superfluous ID or CLASS, and instead use the equivalent of
the :first-child pseudo-selector. As I doubt :first-child is well
supported, I will probably try UL + LI to use the adjacent element
selector within the navigation (although I think IE5 and 6 will fail on
that).

(As an aside, my header and footer already place vertical separators and
arrows using :first-child and :before pseudo selectors. This gets them
out of my HTML. IE6 and IE7 ignore them. As the failure is cosmetic, I
will continue to use them. )

--
http://www.ericlindsay.com
Jan 14 '07 #23

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

Similar topics

1
3320
by: JKenyon | last post by:
I am attempting to display two images on a web page. The second "image" is actually two images, one overlaid on the other. The first one is aligned on the left using float:left. I have enclosed the next two images in a <DIV> tag with float: right in order to force the containing content to be aligned on the right. I also set position:relative so that any absolute positioning within the <DIV> will be relative to the itself. The...
9
17977
by: leegold | last post by:
Why does float:right cause a line break? Try the code below. Is there a fix? I want the link on the same line as the text. Thanks <html> <head> <STYLE> span.linkpos { float:right; clear: none; color:blue; } </style> </head>
3
19416
by: Michael Shell | last post by:
Greetings, I've been playing with CSS inline floats of <span> elements and the results are not quite what I would expect. In the example attached at the end of this post, I would expect the floated span 2 to be on the same line as span 1, but instead it is on the same line as span 3, which is on the line below span 1. Eric Meyer's CSS pocket reference gives a clue as to why this is so: "A floated element will generate a block-level box...
5
4926
by: Oliver Block | last post by:
Hello everybody, I wonder why a <span style="float:right">some text</span> might be displayed out of a surrounding div element. It is shifted to the next line. I thougt it is supposed to appear inside the surrounding div. There is
15
16614
dlite922
by: dlite922 | last post by:
I'm back again, Intro: I've got a floating div (outerDIV) with fixed width that contains an image (IMG) and a div that contains a short text (innerDIV) Problem: In FF, the innerDIV is displaying under the IMG because outerDIV is not wide enough to contain both of them (in some instances). In the instances where the outerDIV is wide, I don't have this problem. IE wraps the text but still keeps it to the right of the IMG. FF doesn't...
2
6429
by: paragpdoke | last post by:
Hello All. I have a weird observation regarding the CSS float style for span. Allow me to share details before asking my question: Screen resolution: 1024x768 (I know my monitor is outdated; it can't display higher than this) Link: http://www.w3schools.com/js/tryit.asp?filename=try_dom_style_cssfloat Text entered in the left side: <html> <body>
0
9591
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
9425
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
10225
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...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
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,...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.