How to rotate text 90 degrees inline

54.5k views Asked by At

How do I rotate text 90 degrees without using the style sheet? I have placed the following instruction in the header area of the page:

<style>
div.rotate-text {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
</style>

Then I placed the following around the paragraph in question.

<div id="rotate-text">
<p>My paragraph</p>
</div>

But its not working and hence my question.

5

There are 5 answers

2
sjahan On BEST ANSWER

Here is a small visual example:

#rotate-text {
   width: 25px;
   transform: rotate(90deg);
}
<div id="rotate-text">
  <p>My paragraph</p>
</div>

0
Ehsan On

you use of id in html code, so you must use of # in css.

Change:

div.rotate-text {

To:

div#rotate-text {

div#rotate-text {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  width: 100px;
  transform-origin: top left;
  margin: 50px;
}
<div id="rotate-text">
  <p>My paragraph</p>
</div>

1
Freestyle09 On

You can use css property writing-mode

writing-mode: vertical-rl

or

writing-mode: vertical-lr

Or using transform property: rotate

transform: rotate(90deg)
0
dvdmn On

Writing mode is better for text content, with transform: rotate() the text container still stays with the horizontal dimensions.

writing-mode: vertical-rl; //Rotate -90deg
writing-mode: vertical-lr; //Rotate 90deg
0
Hokascha On

to get the text reading from the bottom up, use this:

#rotate-text {
   writing-mode: vertical-lr;
   transform: scale(-1, -1);
}
<div id="rotate-text">
  <p>My paragraph</p>
</div>