Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Layout - Simulated table cells

Status
Not open for further replies.

JeffChastain

Programmer
Nov 11, 2002
2
US
I am playing with using CSS for all of my layouts - i.e. no tables. I am needing to simulate the effect of having a table row split into two cells and I am running into problems.

I have a <div representing a page header. I need to split that header into two pieces - one aligned left, and one aligned right. The table code I would use would be as follows ...

<table ...
<tr>
<td align=left&quot; valign=&quot;middle&quot;>Left Cell Content</td>
<td align=&quot;right&quot; valign=&quot;middle&quot;>>Right Cell Content</td>
</tr>
</table>

So how do I do this in CSS? This does not appear to work.

<div id=&quot;header&quot;>
<span style=&quot;text-align: left; vertical-align: middle;&quot;>Left Cell Content</span>
<span style=&quot;text-align: right; vertical-align: middle;&quot;>Right Cell Content</span>
</div>

Thanks
-- Jeff
 
Alignment only works in block elements. <span/> is an inline element. Some browsers support CSS styles promoting inline elements to block elements by assigning them width and height properties.

<span style=&quot;width:300;height:50;text-align:left&quot;>Hello</span>

Hope this helps
-pete
 
I often use something like this to achieve that effect:
Code:
-------CSS---------

<style>
div#banner img#logo { float: right; }
</style>

-------HTML--------

<div id=&quot;banner&quot;>
<img id=&quot;logo&quot; alt=&quot;logo&quot; src=&quot;logo.gif&quot; />
<h1>MySite.com</h1>
</div>
petey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top