Easy Vertical Text Online

A few weeks back, I was doing a project where I needed to display a table of information with many columns on a web page. The value in each cell was a short word, but the labels for each column could be long.

  Something Number One Something Number Two Something Number Three Something Number Four Something Number Five
Server 1 BAD OK OK BAD OK
Server 2 OK BAD OK OK OK

With typical HTML, this would mean the data table would stretch too wide (horizontal scrolling), or I’d need to use a very small (illegible?) type size on the column headers.

If I could make the column headers vertical, then the space issue would be resolved. The only browser that can rotate text on the fly is Safari 3, so the only other typical choice would be to render the text as an image in Photoshop or similar software.

Poking through the PHP GD library manual pages, I found my answer — I could render text using PHP/GD on the fly, and deliver it to the client in <img> tags. I implemented a solution for my app, but then decided that I could make this more widely available. So vtext.info was born.

Here is that same data table, but with vertical text generated on the fly by vtext.info:

  Something Number One Something Number Two Something Number Three Something Number Four Something Number Five
Server 1 BAD OK OK BAD OK
Server 2 OK BAD OK OK OK

So now anyone can programatically generate rotated text in any color, and choosing from a set of basic fonts. The image tag above looks like this:

<img src="http://vtext.info/img?string=Something+Number+Five&color=000000&bgcolor=FFFFFF&face=Sans" alt="Something Number Five" >

So it should be easy to see how to programmatically change the text, color, or font face.

vtext.info screenshot

The system has a built-in caching layer, so I don’t get squeamish if someone decides to use the img tag format above.

Please let me know what you think of this! Maybe someone else will find it useful.

Leave a Comment