0

I've been scouring the web for hours now on many different forums, but no one seems to have the answers I need. How do I align my text vertically in a table cell? Like that: But without spaces

V

E

R

T

I

C

A

L

Here is my code:

.VerticalText {
    -ms-writing-mode: tb-lr;
    -webkit-writing-mode: vertical-lr;
    -moz-writing-mode: vertical-lr;
    }
<table width="98%" border="1" style="">
      <tbody>
        <tr>
          <table width="98%" border="1" style="">
      <tbody>
        <tr>
          <td rowspan="2">TEXT</td>
          <td rowspan="2">TEXT</td>
          <td colspan="7" align="center">TEXT</td>
          <td rowspan="2">TEXT</td>
        </tr>
        <tr>
          <td class="VerticalText">TEXT</td>
          <td>VERTICAL TEXT</td>
          <td>VERTICAL TEXT</td>
          <td>VERTICAL TEXT</td>
          <td>VERTICAL TEXT</td>
          <td>VERTICAL TEXT</td>
          <td>VERTICAL TEXT</td>
        </tr>
      </tbody>
    </table>

I have tried text orientation, textdirection, etc.

I'm lost, can someone help?

Johannes
  • 64,305
  • 18
  • 73
  • 130
Emma S
  • 3
  • 5

1 Answers1

0

You can wrap the text in a span, make that a block element and give it a very small width (so that only one letter fits in there) and also word-break: break-all;, so the words actually break into single letters. (I assigned the changed .VerticalText class to the span elements in my example below)

.VerticalText {
  display: block;
  width: 0.9em;
  word-break: break-all;
}
<table width="98%" border="1" style="">
  <tbody>
    <tr>
      <table width="98%" border="1" style="">
        <tbody>
          <tr>
            <td rowspan="2">TEXT</td>
            <td rowspan="2">TEXT</td>
            <td colspan="7" align="center">TEXT</td>
            <td rowspan="2">TEXT</td>
          </tr>
          <tr>
            <td>TEXT</td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
            <td><span class="VerticalText">VERTICAL TEXT</span></td>
          </tr>
        </tbody>
      </table>
Johannes
  • 64,305
  • 18
  • 73
  • 130