CSS Vertical Text

By  on  

Almost every HTML element we create is thought of in the frame of horizontal.  We pay much more attention to widths than we do heights, especially when it comes to text within them. Sometimes we do, however, want to display element text in a vertical fashion.  In the old days of crippled Internet Explorers, this was mostly a losing battle.  These days, however, vertical text is a breeze.  Here's how to do it!


Vertical text is accomplished easily these days with CSS transforms:

.vertical-text {
	transform: rotate(90deg);
	transform-origin: left top 0;

Depending on which direction you'd like the text to display vertically, the rotation will be different, but it's that rotate value which will make the text vertical.  Here's a helpful tip:

.vertical-text {
	float: left;

Floating the element will essentially emulate an auto width!

CSS transforms make loads possible, and are much more powerful than simply turning text vertical, but with the code provided above, the job is done.  Isn't progress grand?

Recent Features

  • By
    Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you've got something really neat.  Unfortunately each CSS cube tutorial I've read is a bit...

  • By
    5 More HTML5 APIs You Didn’t Know Existed

    The HTML5 revolution has provided us some awesome JavaScript and HTML APIs.  Some are APIs we knew we've needed for years, others are cutting edge mobile and desktop helpers.  Regardless of API strength or purpose, anything to help us better do our job is a...

Incredible Demos

  • By
    Create Keyboard Shortcuts with Mousetrap

    Some of the finest parts of web apps are hidden in the little things.  These "small details" can often add up to big, big gains.  One of those small gains can be found in keyboard shortcuts.  Awesome web apps like Gmail and GitHub use loads of...

  • By
    HTML5 Datalist

    One of the most used JavaScript widgets over the past decade has been the text box autocomplete widget.  Every JavaScript framework has their own autocomplete widget and many of them have become quite advanced.  Much like the placeholder attribute's introduction to markup, a frequently used...


  1. MaxArt

    To create vertical text for IE8 and older, you can rely on the CSS property writing-mode: tb-rl; eventually adding the legacy filter: flipv fliph;

  2. Lewis Walsh

    This is great. Though I tend to think of vertical text as the orientation of the letters being upright, just beneath each other.

  3. You sir, have always something cool here!


  4. For RTL langs, rotate -90deg

  5. Gurmukh

    display: inline-block; also works instead of float: left;

  6. Jozef Remen

    What about vertical text with letters not rotated, just every one below another? Like:

    I think this really can only be achieved with JS to wrap each letter to and then:

    .vertical-text span {transform: rotate(-90deg)}

    I highly doubt it’s possible just with CSS

  7. isti37

    It’s possible, just create a container with the fixed width of one letter size according to the size of the font and the text will wrap line by line (letter by letter) if you set word-wrap to break-word.

  8. Jozef Remen

    Isti37: great solution, very elegant. Thanks!

  9. Add this css also to help complete the experience:

    .vertical-text {
        cursor: vertical-text;
  10. @Jozef Remen props! The only issue is spaces between words this way. They are huge and line-height only works as letter spacing. I guess you’d have to add for each return line. Any other ideas?

  11. With CSS, how would I rotate the “Signup” text?

    #yjsg_sidepanel_open:after {
            content: "\Signup";
  12. huda

    how do I show the heading in 2 lines when rotating text?

  13. Mister

    Try to squeeze your vertical text for example into 4% width DIV and it won’t work. I wanted to make a vertical thin text line with width=4%; and height=100%; (height=vertical so I thought I’d be fine) but it takes the real width of your !horizontal! text and simply rotates it. Thus, all your neighboring divs are completely messed up. You have to measure (somehow?) and assign the width of your horizontal text first and only then you will get the mess this solution creates, otherwise it won’t work at all. Awkward. This method will only work OK if the width property of the place where you want to set your vertical text to this way doesn’t matter.

  14. .texto-vertical-3 {
      word-wrap: break-word;

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!