1

I would like to render text vertically one by one using CSS. If using rotation method, we can get like below,

Actual rotation

But I am expected to render the text like below,

Expected output

Could anybody tell me your suggestion on this?

Note: I am setting this text using 'content:attr(data-content)' in CSS and data-content is "HELLO".

Ponmalar
  • 6,871
  • 10
  • 50
  • 80

3 Answers3

3

You can break each character of content:attr(data-content) like following way:

.test::after {
    content: attr(data-content);
    font-size: 25px;
}
.test {
    width: 0;
    word-break: break-all;
}
<div class="test" data-content="Hello"></div>
ketan
  • 19,129
  • 42
  • 60
  • 98
0

How about this:

h1 span { display: block; }
<h1>
   <span> H </span>
   <span> E </span>
   <span> L </span>
   <span> L </span>
   <span> O </span>
  </h1>

or you can try like this using word-wrap: break-word;:

h1 {
    width: 50px;
    font-size: 50px;
    word-wrap: break-word;
  }
<h1> HELLO </h1>
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

Try using this with simple HTML instead of with CSS

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Vertical Text</title>
 
<style>
  h1 span { display: block; }
</style>
</head>
<body>
  
  <h1>
   <span> N </span>
   <span> E </span>
   <span> T </span>
   <span> T </span>
   <span> U </span>
   <span> T </span>
   <span> S </span>
  </h1>
   
</body>
</html>