473,770 Members | 2,065 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 6429
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
2392
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
1788
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
6615
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
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...
10
10294
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
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
1909
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
51555
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
25933
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
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
10057
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
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
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
5312
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
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
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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.