- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS writing-mode Control Text Flow Direction
Available options include horizontal-tb, vertical-rl, vertical-lr, sideways-rl, and sideways-lr.
Formal Syntax
The formal syntax for the writing-mode property is defined as follows:
writing-mode = horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lrEach value specifies a different direction for the layout of text and block-level elements. The syntax indicates that only one of these values must be specified for the writing-mode property.
Examples
Basic Horizontal Text Flow
In this example, we’ll use the horizontal-tb value to demonstrate the default horizontal text flow from left to right.
HTML:
<!DOCTYPE html><html><head> <title>writing-mode Property</title> <style> p.horizontal-tb { width: 300px; height: 100px; border: 1px solid black; writing-mode: horizontal-tb; color: white; background: green; } </style></head><body style="text-align: center;"> <h1 style="color:green;">Example: Horizontal Text Flow</h1> <p class="horizontal-tb"> This is an example of horizontal text flow from left to right. </p></body></html>Vertical Text Flow from Right to Left
In this example, we’ll use the vertical-rl value to demonstrate vertical text flow from top to bottom, with the next line positioned to the left of the previous line.
HTML:
<!DOCTYPE html><html><head> <title>writing-mode Property</title> <style> p.vertical-rl { width: 200px; height: 200px; border: 1px solid black; writing-mode: vertical-rl; color: white; background: green; } </style></head><body style="text-align: center;"> <h1 style="color:green;">Example: Vertical Text Flow (Right to Left)</h1> <p class="vertical-rl"> This is an example of vertical text flow from top to bottom, with the next line positioned to the left of the previous line. </p></body></html>Vertical Text Flow from Left to Right
In this example, we’ll use the vertical-lr value to demonstrate vertical text flow from top to bottom, with the next line positioned to the right of the previous line.
HTML:
<!DOCTYPE html><html><head> <title>writing-mode Property</title> <style> p.vertical-lr { width: 200px; height: 200px; border: 1px solid black; writing-mode: vertical-lr; color: white; background: green; } </style></head><body style="text-align: center;"> <h1 style="color:green;">Example: Vertical Text Flow (Left to Right)</h1> <p class="vertical-lr"> This is an example of vertical text flow from top to bottom, with the next line positioned to the right of the previous line. </p></body></html>Sideways Text Flow from Right to Left
In this example, we’ll use the sideways-rl value to demonstrate sideways text flow from top to bottom, with the glyphs set sideways toward the right.
HTML:
<!DOCTYPE html><html><head> <title>writing-mode Property</title> <style> p.sideways-rl { width: 200px; height: 200px; border: 1px solid black; writing-mode: sideways-rl; color: white; background: green; } </style></head><body style="text-align: center;"> <h1 style="color:green;">Example: Sideways Text Flow (Right to Left)</h1> <p class="sideways-rl"> This is an example of sideways text flow from top to bottom, with the glyphs set sideways toward the right. </p></body></html>Sideways Text Flow from Left to Right
In this example, we’ll use the sideways-lr value to demonstrate sideways text flow from bottom to top, with the glyphs set sideways toward the left.
HTML:
<!DOCTYPE html><html><head> <title>writing-mode Property</title> <style> p.sideways-lr { width: 200px; height: 200px; border: 1px solid black; writing-mode: sideways-lr; color: white; background: green; } </style></head><body style="text-align: center;"> <h1 style="color:green;">Example: Sideways Text Flow (Left to Right)</h1> <p class="sideways-lr"> This is an example of sideways text flow from bottom to top, with the glyphs set sideways toward the left. </p></body></html>Browser Compatibility
The writing-mode property is widely supported across modern browsers. Below is a table outlining the compatibility of the writing-mode property across various browsers:
| Browser | Version | Initial Support Date |
|---|---|---|
| Google Chrome | 48.0 | January 2016 |
| Firefox | 41.0 | September 2015 |
| Internet Explorer | 12.0 | July 2015 |
| Edge | 12.0 | July 2015 |
| Opera | 35.0 | February 2016 |
| Safari | 10.1 | September 2017 |
Summary
The writing-mode property is a powerful CSS tool for controlling the direction of text flow, making it especially useful for multilingual websites and creative page layouts. While most modern browsers support the writing-mode property, it’s important to check compatibility and use appropriate fallbacks for older browsers that may not fully support all values.
For the most up-to-date information on browser compatibility, refer to the MDN Web Docs Browser Compatibility Data.
See Also
To enhance your understanding and usage of the writing-mode property, you may find the following related CSS properties and resources helpful:
Related CSS Properties
- [
direction]WebsiteUrl- The
directionproperty specifies the text direction/writing direction within a block-level element. This property is often used in conjunction withwriting-modeto control text flow in different languages.
- The
- [
unicode-bidi]WebsiteUrl- The
unicode-bidiproperty is used to control the text direction for the Unicode Bidirectional Algorithm. It is particularly useful for handling mixed-direction text, such as combining left-to-right and right-to-left scripts.
- The
- [
text-orientation]WebsiteUrl- The
text-orientationproperty specifies the orientation of text within a line box. It is often used to fine-tune the appearance of vertical text.
- The
- [
text-combine-upright]WebsiteUrl- The
text-combine-uprightproperty allows multiple characters to be combined into the space of a single character in vertical text layouts, particularly useful for East Asian typography.
- The
- [CSS Logical Properties]WebsiteUrl
- CSS logical properties provide a way to write CSS that adapts to the writing mode. They include properties like
block-size,inline-size, andmargin-inline-start, which adjust based on the writing mode and direction of the text.
- CSS logical properties provide a way to write CSS that adapts to the writing mode. They include properties like
Additional Resources
- [Styling vertical text (Chinese, Japanese, Korean and Mongolian)]WebsiteUrl
- This article on W3.org provides a comprehensive guide to styling vertical text for languages that traditionally use vertical writing systems, such as Chinese, Japanese, Korean, and Mongolian.
- [CSS writing modes]WebsiteUrl
- The CSS writing modes module defines the CSS writing modes, which control the direction of text flow and block layout. This module includes detailed specifications and examples for using the
writing-modeproperty.
- The CSS writing modes module defines the CSS writing modes, which control the direction of text flow and block layout. This module includes detailed specifications and examples for using the
- [Creating vertical form controls]WebsiteUrl
- This guide explains how to create vertical form controls using CSS writing modes, ensuring that form elements align correctly with vertical text.
- MDN Web Docs
- The MDN Web Docs provide extensive documentation on CSS properties, including the
writing-modeproperty, with examples, browser compatibility information, and detailed explanations.
- The MDN Web Docs provide extensive documentation on CSS properties, including the
Tutorials and Guides
- [CSS Tricks: Understanding CSS Writing Modes]WebsiteUrl
- This tutorial on CSS Tricks offers an in-depth look at CSS writing modes, with practical examples and tips for implementation.
- [W3Schools CSS writing-mode Property]WebsiteUrl
- W3Schools provides a concise reference and examples for the
writing-modeproperty, suitable for beginners and intermediate users.
- W3Schools provides a concise reference and examples for the
By exploring these related properties and resources, you can gain a deeper understanding of how to effectively use the writing-mode property to create well-designed and accessible web pages.
สร้างเว็บไซต์ 1 เว็บ ต้องใช้งบเท่าไหร่? เจาะลึกทุกองค์ประกอบ website development cost อยากสร้างเว็บไซต์แต่ไม่มั่นใจในเรื่องของงบประมาณ อ่านสรุปเจาะลึกตั้งแต่ดีไซน์, ฟังก์ชัน และการดูแล พร้อมตัวอย่างงบจริงจาก Till it’s done ที่แผนชัด งบไม่บานปลายแน่นอน
Next.js สอน 14 ขั้นตอนเบื้องต้น: สร้างโปรเจกต์แรกใน 30 นาที เริ่มต้นกับ Next.js ใน 14 ขั้นตอนเพียงแค่ 30 นาที พร้อม SSR/SSG และ API Routes ด้วยตัวอย่างโค้ดง่าย ๆ อ่านต่อเพื่อสร้างโปรเจ็กต์แรกได้ทันทีที่นี่
วิธีสมัคร Apple Developer Account เพื่อนำแอปขึ้น App Store ทีละขั้นตอน อยากปล่อยแอปบน App Store ระดับโลก มาอ่านคู่มือสมัคร Apple Developer Account พร้อมเคล็ดลับ TestFlight และวิธีอัปโหลดที่ง่ายในบทความเดียวนี้ได้เลย
TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว
Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์
เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! พูดคุยกับซีอีโอ
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.