CSS Writing Mode

CSS Writing Mode is a fundamental property that allows developers to control the direction in which content flows within a web page. It determines the layout and presentation of text and other elements, such as images and tables. In this article, we will explore the CSS Writing Mode property in detail and provide examples to help you understand its usage.

The CSS Writing Mode property defines how content flows vertically or horizontally within a container. It has four possible values:

1. horizontal-tb (default): This value sets the content to flow horizontally from top to bottom. It is the default value for most web pages.

2. vertical-rl: This value sets the content to flow vertically from right to left. It is commonly used in languages that are written from right to left, such as Arabic or Hebrew.

3. vertical-lr: This value sets the content to flow vertically from left to right. It is used in languages that are written from left to right, such as Japanese or Chinese.

4. sideways-rl: This value sets the content to flow horizontally from right to left, with each line rotated 90 degrees counterclockwise. It is often used for vertical text in Asian languages.

Let’s explore some examples to better understand how CSS Writing Mode works:

Example 1: Horizontal Text Flow
“`

.container {
writing-mode: horizontal-tb;
}

This is an example of horizontal text flow.

“`

In this example, the text within the `

` element will flow horizontally from top to bottom, as it is the default behavior.

Example 2: Vertical Text Flow (Right to Left)
“`

.container {
writing-mode: vertical-rl;
}

This is an example of vertical text flow from right to left.

“`

In this example, the text within the `

` element will flow vertically from right to left. This is commonly used in languages like Arabic or Hebrew.

Example 3: Vertical Text Flow (Left to Right)
“`

.container {
writing-mode: vertical-lr;
}

This is an example of vertical text flow from left to right.

“`

In this example, the text within the `

` element will flow vertically from left to right. This is commonly used in languages like Japanese or Chinese.

Example 4: Sideways Text Flow
“`

.container {
writing-mode: sideways-rl;
}

This is an example of sideways text flow.

“`

In this example, the text within the `

` element will flow horizontally from right to left, with each line rotated 90 degrees counterclockwise. This is often used for vertical text in Asian languages.

CSS Writing Mode is a powerful property that allows developers to control the flow of content within a web page. By understanding its various values and their applications, you can create more visually appealing and accessible websites.

Remember, the CSS Writing Mode property is just one aspect of CSS that contributes to the overall design and layout of a web page. It can be combined with other CSS properties to achieve the desired presentation.

I hope this article has provided you with a clear understanding of CSS Writing Mode and its usage. Experiment with different values and explore its possibilities to enhance your web design skills.

Scroll to Top