Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS text-orientation Property

Posted in CSS Tutorial
Updated on Oct 13, 2024
By Mari Selvan
๐Ÿ‘๏ธ 19 - Views
โณ 4 mins
๐Ÿ’ฌ 1 Comment
CSS text-orientation Property

Photo Credit to CodeToFun

๐Ÿ™‹ Introduction

The text-orientation property in CSS is used to define the orientation of text within a line when dealing with vertical writing modes.

This property is particularly useful for languages like Chinese, Japanese, and Korean, which are often written vertically. It allows for finer control over the display of characters in a vertical context, ensuring they are presented in the most readable and aesthetically pleasing manner.

๐Ÿ’ก Syntax

The syntax for the text-orientation property is straightforward. It can be applied to any element that supports vertical writing modes.

Syntax
Copied
Copy To Clipboard
element {
  text-orientation: value;
}

๐ŸŽ›๏ธ Default Value

The default value of the text-orientation property is mixed, which means the text will use an upright orientation for characters that are typically written upright and a sideways orientation for characters that are typically written sideways.

๐Ÿ  Property Values

ValueDescription
mixedThis is the default value. Text is displayed upright for characters that have an upright version and sideways for characters that do not.
uprightAll characters are displayed upright.
sidewaysAll characters are displayed sideways, rotated 90 degrees.
sideways-rightAll characters are displayed sideways, rotated 90 degrees to the right.
use-glyph-orientationUses the glyph's orientation defined by the font.

๐Ÿ“„ Example

In this example, we'll apply the text-orientation property to a vertical text container.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS text-orientation Example</title>
  <style>
    .vertical-text {
      writing-mode: vertical-rl;
      text-orientation: upright;
      border: 1px solid #000;
      padding: 10px;
      width: 100px;
      height: 200px;
    }
  </style>
</head>
<body>
  <h1>Text Orientation Example</h1>
  <div class="vertical-text">
    ใ“ใ‚Œใฏ็ธฆๆ›ธใใฎใƒ†ใ‚ญใ‚นใƒˆใงใ™ใ€‚
  </div>
</body>
</html>

๐Ÿ–ฅ๏ธ Browser Compatibility

The text-orientation property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

๐ŸŽ‰ Conclusion

The text-orientation property is a valuable tool for web developers working with vertical text layouts.

By customizing the orientation of text within a line, you can create more readable and visually appealing content, particularly for languages that use vertical writing. Experiment with different values to see how this property can enhance the presentation of your vertical text.

๐Ÿ‘จโ€๐Ÿ’ป Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
๐Ÿ‘‹ Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy