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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rotate text in a tablecell 90°

Status
Not open for further replies.

Smarty

Programmer
Apr 12, 2001
191
BE
Hey,

Is it possible to rotate text in a table cell 90° (like a column header in excell)? And if so, how?

Thanx,

Smarty
 
Sorry... thought you wanted images. Mental Note: Re-read the question BEFORE posting. [blush]

Pete.


Web Developer / CMS (Aptrix / LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 
You could easily fake it to work in all browsers by using a span with a very small width:

Code:
<HTML>
<HEAD></HEAD>
<BODY>

<TABLE WIDTH=&quot;75%&quot; CELLPADDING=&quot;1&quot; CELLSPACING=&quot;0&quot; BORDER=&quot;1&quot;>
<TR>
	<TD WIDTH=&quot;20%&quot;> </TD>
	<TD WIDTH=&quot;40%&quot;>X Text 1</TD>
	<TD WIDTH=&quot;40%&quot;>X Text 2</TD>
</TR>
<TR>
	<TD><SPAN STYLE=&quot;width:1px;display:block;&quot;>Y T e x t 1<SPAN></TD>
	<TD> </TD>
	<TD> </TD>
</TR>
<TR>
	<TD><SPAN STYLE=&quot;width:1px;display:block;&quot;>Y T e x t 2</SPAN></TD>
	<TD> </TD>
	<TD> </TD>
</TR>
<TR>
	<TD>Y Text 3</TD>
	<TD> </TD>
	<TD> </TD>
</TR>
</TABLE>

</BODY>
</HTML>

The reason I've put SPAN tags inside the TD tag is so that you can mix and match horizontal and vertical text (see row 3 of the above demo).

As you can see, the only proviso to this working, is thta you have to put spaces after each letter in your vertical titles.

Works fine in IE6, Opera 7, NN 7, and Mozilla 1.5... Will most likely work on most browsers, I'd say.

Hope this helps!

Dan
 
Dan, he wants to rotate the text through 90&deg; so that it reads up or down the page instead of across - as can be seen on the page I linked to (if you use IE to view it!).

For your method, you might as well do this:
[tt]
<td>T<br>e<br>x<br>t<br>1</td>
[/tt]
It'll have the same effect and work on all possible browsers.

-- Chris Hunt
 
I did it with the CSS style. It worked as I wanted it to work. Also menthal note: while printing, the text rotates the other way around.

Thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top