To solve this for non-IE
Check for browser type:
If IE use "style" as above with tl-rb
Otherwise create an image of vertical text and use "img"
(Firefox is only CSS2 compliant not CSS3)
Main Topics
Browse All TopicsHow to show vertical text in IE and firefox using java script. I used the below script and it works fine in IE but in firefox it is not working (in firefox it is showing the text horizontally)
<style>
.vertical
{
writing-mode: tb-rl;
filter: flipH flipV;
letter-spacing:2px;
}
</style>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can position text vertically in any browser by very simple means - just by adding a linebreak after each letter, e.g.:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>Vertical</title>
</head>
<body>
<div style="text-align:center; width:40px; margin-right:40px;">T<br>h
</body>
</html>
or using a table:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>Vertical</title>
</head>
<body>
<table><tr><td style="text-align:center; width:100px;">T<br>h<br>i<
</body>
</html>
Also have a look at these vertical lists:
http://www.cssplay.co.uk/m
You can add the line-breaks automatically to a any string. Here's a little script that does it (cross-browser):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>Vertical</title>
<style>
#vertical {width:20px; text-align:center;}
</style>
<script>
var str='This is a text that should display vertically...';
var result='';
function showVerticalText() {
for (var i=0;i<str.length;i++) {
result+=(str.charAt(i)!=' ') ? str.charAt(i)+'<br>' : ' <br>';
}
document.getElementById('v
}
</script>
</head>
<body onload="showVerticalText()
<div id="vertical"><div>
</body>
</html>
the above code will show the text vertically 1st time when page loads but when the text gets changed after 10 sec that time how I will be able to change the allignment.
The current code that i am using is as below
<style>
.vertical
{
writing-mode: tb-rl;
ilter: flipH flipV;
letter-spacing:2px;
}
</style>
<script language='JavaScript1.2' type='text/javascript'>
var variableslide=new Array()
variableslide[0]=['img/1.g
variableslide[1]=['img/2.g
variableslide[2]=['img/3.g
</Script>
I am using a array of images with text and it is getting changed after 10 sec (only relavent code I have pasted, image rotation code I have removed).
>the above code will show the text vertically 1st time when page loads but when the text gets changed after 10 sec that time how I will be able to change the allignment.
Just pass the new text to the showVerticalText() function (I've slightly changed the function, see below).
Have a look at this example (type repeatedly some text into the textbox and press the button):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>Vertical</title>
<style>
#vertical {width:20px; text-align:center;}
</style>
<script>
function showVerticalText(str) {
var result='';
for (var i=0;i<str.length;i++) {
result+=(str.charAt(i)!=' ') ? str.charAt(i)+'<br>' : ' <br>';
}
return result;
}
function changeText() {
var theText=document.getElemen
document.getElementById('v
}
</script>
</head>
<body>
<input type="text" id='txt'>
<br>
<input type="button" onClick="changeText();">
<br>
<div id="vertical"><div>
</body>
</html>
And this will refresh the display every 3 seconds (keep changing the text in the textbox...)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>Vertical</title>
<style>
#vertical {width:20px; text-align:center;}
</style>
<script>
function showVerticalText(str) {
var result='';
for (var i=0;i<str.length;i++) {
result+=(str.charAt(i)!=' ') ? str.charAt(i)+'<br>' : ' <br>';
}
return result;
}
function changeText() {
var theText=document.getElemen
document.getElementById('v
}
window.onload=function(){ setInterval('changeText();
</script>
</head>
<body>
<input type="text" id='txt'>
<br>
<div id="vertical"><div>
</body>
</html>
I have setup the code in the site "http://www.middle-east-mo
Well, the main idea would be to replace strings like 'BBC' and 'ABC News' with
showVerticalText('BBC');
and
showVerticalText('ABC News');
you could try something like this:
<script type='text/javascript'>
var s='';
s=showVerticalText('BBC');
var variableslide=new Array();
variableslide[0]=['/LeadPh
s=showVerticalText('ABC News');
variableslide[1]=['/LeadPh
function showVerticalText(str) {
var result='';
for (var i=0;i<str.length;i++) {
result+=(str.charAt(i)!=' ') ? str.charAt(i)+'<br>' : ' <br>';
}
return result;
}
</script>
The above code would of course *replace* this script block from your page! :
<script language='JavaScript1.2' type='text/javascript'>
var variableslide=new Array()
variableslide[0]=['/LeadPh
variableslide[1]=['/LeadPh
</Script>
hi TName
thanks for ur sample code, it is somewhat working, have a look at http://www.middle-east-mon
But problem is that becuase of the <br> after each char a gap is coming which is making the text very long, is it possible to change the script so that it looks like http://www.middle-east-mon
Business Accounts
Answer for Membership
by: TNamePosted on 2007-05-02 at 23:16:01ID: 19021306
Hi, this isn't javascript (it isn't a script at all), it's just a CSS ruleset (it describes how an HTML element should be presented).
CR-css3-te xt-2003051 4/#writing - mode
Writing-mode is supported by IE but not by Gecko-based browsers like FF. Apparently, it will be part of CSS3:
http://www.w3.org/TR/2003/