Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Vertical Text, with Horizontal Letters in CSS
On a web page, you may need to set a vertical text and that too with horizontal letters. By combining the text-orientation: upright and writing-mode: vertical-rl properties, we can display vertical text with horizontal letters in CSS.
Syntax
selector {
writing-mode: value;
text-orientation: value;
}
Key Properties
| Property | Value | Description |
|---|---|---|
writing-mode |
vertical-rl |
Lines flow vertically from top to bottom, horizontally from right to left |
text-orientation |
upright |
Characters remain upright and not rotated |
Example 1: Basic Vertical Text
The following example demonstrates how to create vertical text with horizontal letters using a heading element −
<!DOCTYPE html>
<html>
<head>
<style>
h4 {
text-orientation: upright;
writing-mode: vertical-rl;
line-height: 3;
box-shadow: inset 0 0 3px khaki;
padding: 20px;
height: 300px;
}
</style>
</head>
<body>
<h4>Cricket is love</h4>
</body>
</html>
A vertical heading "Cricket is love" appears with letters standing upright, flowing from top to bottom with a khaki shadow border.
Example 2: Multiple Vertical Texts with Flexbox
This example creates multiple vertical text columns of equal size using flexbox layout −
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
gap: 10px;
margin: 0;
padding: 20px;
}
p {
text-orientation: upright;
writing-mode: vertical-rl;
line-height: 3;
box-shadow: inset 0 0 13px orange;
flex: 1;
padding: 20px;
height: 200px;
text-align: center;
}
</style>
</head>
<body>
<p>One</p>
<p>Two</p>
<p>Three</p>
<p>Four</p>
</body>
</html>
Four equal-width vertical text columns appear side by side, each containing upright letters with orange shadow borders.
Conclusion
The combination of writing-mode: vertical-rl and text-orientation: upright creates vertical text with horizontal letters. This technique is useful for creating unique layouts and is commonly used in East Asian typography.
Advertisements
