473,721 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Span shifts down when float=right

62 New Member
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.as...style_cssfloat
Text entered in the left side:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <span>This is some text. This is some text.</span><span style="float:right;">Some more text on the right</span>
  5. </body>
  6. </html>
  7.  
For some reason, Firefox (3.0.1 on WinXP SP3) and IE (6 on WinXP SP3) display the right span on a different line. However, Google chrome (3.0.195.25) displays it in the same line as I want it to. There is a note on the w3schools page saying if the text needs more space, it will occupy the next line. But in my case I am sure that the text is not needing more space (I tried creating borders and confirm that the text does not overlap). Even then it shifts down :-(.

Can someone help me with this ? My intent is to display both span elements on the same line.

Thanks in advance,
Parag Doke
Oct 13 '09 #1
2 6426
drhowarddrfine
7,435 Recognized Expert Expert
That's because <div> is a block element which automatically takes up the full width of the browser's viewport, in this case. Floating the span removes it from the normal flow of the div but will place it below that.

If you float the div left and set a width, you'll see everything on one line. Why Chrome is not acting the same as Firefox, I don't know (did not test myself).

Do not compare IE6 to Firefox. For that matter, do not compare any version of IE to any other browser. Internet Explorer is almost 12 years behind every other browser in modern standards and practices and the worst browser on the planet. Always, always check with the more modern browsers first to see if your markup is correct. Then look at IE to see if/when it screws things up.
Oct 13 '09 #2
paragpdoke
62 New Member
Hello drhowarddrfine.
Many thanks for your inputs. I was able to get it work using the following:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <div style="float: left;">This is some text. This is some text.</div><div style="float:right;">Some more text on the right</div>
  4. </body>
  5. </html>
  6.  
Regards,
Parag Doke
http://paragpdoke.blogspot.com
Oct 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2387
by: jon slinn | last post by:
Does anybody know why I can't get a simple two col design to work using the following css? At the moment my columns seem to be arranging left and right correctly but are stacked on top of each other? the site is : http://www.rockshore.net/html/hol2.html div.lh-col{ width: 18%; float:left; border: solid #333333;
0
1782
by: PJ | last post by:
http://www.paulwalker.tv/test.htm I want the Asset List title to float to the left in the cell and the <select> and <input> elements to float to the right. However, in Mac IE, the <select> and <input> elements float outside of the table. What is the proper styling for my desired effect? TIA~ PJ
3
6612
by: Günther Stößl | last post by:
Hello I am trying to position two floats inside a table column. <td> <div style="position:relative; width:100%"> <div style="position:absolute; left:0px; width:60%>... </div> <div style="float:right; width:30%></div> </div></td>
1
3319
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...
10
10289
by: Jesper Rønn-Jensen | last post by:
Hope you can help me out on this one. I have a a box that is floated right. Below (in the normal float) I have a wide table. <body> <div style="float:right; width:200px">...</div> <p>This paragraph is showed correctly</p> <table style="width:300px"> <tr><td>This table is not moved downwards in Firefox. </td></tr> <tr><td>IE gets it right.</td></tr>
9
17973
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
1906
by: Leon | last post by:
Is it possible? Say We have a list of suppliers link like A supplier B supplier when right click on a supplier, a context menu(that has "details","view products", etc) appears and click on "view products
22
51539
by: ashkaan57 | last post by:
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:right">blah blah</span> </div> The 2nd text does go to the right but the next line. What am I doing wrong? TIA.
7
25891
by: JackRbt | last post by:
I have a navbar in a div, with several links. The last one is in a <span> because I want it to float to the right by itself. The span does float right, but it shows up below the navbar div. I want it within the div. Is this doable? Thanks. <?php echo "<p>"; echo '<div id="navbar"> <a href="edit_reg.php">edit</a> &nbsp;<a href="undelete.php">undelete</a>
0
8727
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
9365
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
9212
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...
0
8002
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...
1
6664
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
4483
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...
0
4748
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3186
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
2569
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.