Posted almost 6 years ago. Visible to the public. Deprecated.

How to use CSS to rotate text by 90° in IE8 (and modern IEs)

Microsoft does not support IE8 anymore, and neither do we.

If you want to rotate text, you can use CSS transforms in somewhat modern browsers to rotate the container element.
However, if you need to support IE8, transform is unavailable (if need only IE9 support, ignore the following and use -ms-transform).

Here is a solution that worked for me:

Copy
<div class="my-element">Hi!</div>

^

Copy
.my-element { display: inline-block; transform: rotate(90deg); -ms-writing-mode: tb-rl; -ms-transform: none; }

This way, browsers will use CSS transforms when available -- which is on basically all but IE. [1]

To achieve a rotation on IE8 and IE9, we can use writing-mode. Since other browsers understand that as well, we use the vendor-prefixed -ms-writing-mode to target only IE.

However, IEs that do support transform (IE10+) would combine both styles into a 180° rotation which we do not want.
So we reset our transform definition for IEs -- and only them -- by using the -ms- prefix again. That way, IEs will always use -ms-writing-mode.

There is a jsFiddle demo if you want to see it in action.


[1] You may want to use autoprefixer to fill in vendor prefixes automatically.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Arne Hartherz
Last edit:
almost 6 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more