CSS writing-mode Property

You are Here:

CSS writing-mode Property

CSS writing-mode property sets whether lines of text are laid out horizontally or vertically, as well as the direction in which blocks progress.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ border: 1px solid black; width: 200px; height: 150px; } #point{ writing-mode: horizontal-tb; } #point1{ writing-mode: vertical-rl; } #point2{ writing-mode: vertical-lr; } </style> </head> <body> <h1>CSS writing-mode Property</h1> <h2>writing-mode: horizontal-tb</h2> <div id="point"> This is a horizontal-tb. </div> <h2>writing-mode: vertical-rl</h2> <div id="point1"> This is a vertical-rl. </div> <h2>writing-mode: vertical-lr</h2> <div id="point2"> This is a vertical-lr. </div> </body> </html>

Syntax

Using CSS

element{ writing-mode: vertical-rl; }

Using Javascript

object.style.writingMode="vertical-rl";

Animatable

No, writing-mode property is not animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS writing-mode property is horizontal-tb.

Property Value

The following table provides a list of values for CSS writing-mode property.

ValueExplanation
horizontal-tbContent flows horizontally from left to right, vertically from top to bottom.
vertical-rlContent flows vertically from top to bottom, horizontally from right to left.
vertical-lrContent flows vertically from top to bottom, horizontally from left to right.

Using JavaScript

In the following example, we will demonstrate how to change the CSS writing-mode property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ border: 1px solid black; width: 150px; height: 100px; } </style> </head> <body> <h1>CSS writing-mode Property</h1> <div id="point"> This is a div. </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("div")[0]; function myFunction(){ x.style.writingMode = "vertical-rl"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author