Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS writing-mode Property

Posted in CSS Tutorial
Updated on Jul 14, 2024
By Mari Selvan
👁️ 14 - Views
⏳ 4 mins
💬 1 Comment
CSS writing-mode Property

Photo Credit to CodeToFun

🙋 Introduction

The writing-mode property in CSS is used to define the direction and orientation of text. This property is particularly useful for languages that are written vertically, such as Japanese and Chinese, as well as for creating unique layouts where text direction plays a key role.

By using the writing-mode property, you can control whether text is laid out horizontally or vertically and the direction in which lines are stacked.

💡 Syntax

The syntax for the writing-mode property is simple and consists of specifying one of the predefined values.

Syntax
Copied
Copy To Clipboard
element {
  writing-mode: value;
}

🎛️ Default Value

The default value of the writing-mode property is horizontal-tb, which means text is written horizontally and lines are stacked from top to bottom.

🏠 Property Values

ValueDescription
horizontal-tbText is written horizontally, and lines are stacked from top to bottom (default).
vertical-rlText is written vertically, and lines are stacked from right to left.
vertical-lrText is written vertically, and lines are stacked from left to right.
sideways-rlText is written horizontally but rotated 90 degrees counterclockwise, with lines stacked from right to left.
sideways-lrText is written horizontally but rotated 90 degrees clockwise, with lines stacked from left to right.

📄 Example

In this example, we'll change the writing mode of a paragraph to vertical, with lines stacked from right to left.

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 writing-mode Example</title>
  <style>
    p {
      writing-mode: vertical-rl;
      border: 1px solid #000;
      width: 200px;
      height: 100px;
      padding: 10px;
    }
  </style>
</head>
<body>
  <h1>Paragraph with Vertical Writing Mode</h1>
  <p>
    This is a paragraph with the writing mode set to vertical-rl. The text is written vertically, and lines are stacked from right to left.
  </p>
</body>
</html>

🖥️ Browser Compatibility

The writing-mode 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 writing-mode property is a versatile tool for web developers looking to create unique text layouts and support various writing systems.

By controlling the direction and orientation of text, you can enhance the readability and aesthetic appeal of your website. Experiment with different values and see how this property can transform the way your content is displayed.

👨‍💻 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