×

Css Text Orientation

Introduction:

The text-orientation property of CSS is used to specify the orientation of the text characters in the line of content. This property applies only with the vertical writing-mode and not with the text which is in horizontal writing-mode.

This property is used for controlling the display of languages using vertical script and to create vertical table headers.

The text-orientation property is completely dependent on the writing-mode property. So it is mandatory that the writing-mode is set to vertical-rl. If the writing-mode is set to horizontal-tb, text-orientation won't work.

It can be applied to all the element except the table rows, columns, row groups and column groups.

What is writing-mode?

The writing-mode property indicates whether the script/text is displayed vertically or horizontally.

Default value of this property is horizontal-tb

There are three values associated with writing-mode:

Value Description
horizontal-tb This allows the text to flow horizontally from left to right and vertically from top to bottom.
vertical-rl This allows the text to flow vertically from top to bottom and horizontally from right to left.
vertical-lr This allows the text to flow vertically from top to bottom and horizontally from left to right.

Text - orientation property values:

CSS text-orientation has following values:

  • mixed
  • upright
  • sideways
  • sideways-right
  • use-glyph-orientation
  • initial
  • inherit
  • mixed:
    This is the default value of text-orientation and it rotates the horizontal text 90oclockwise. Characters which are already in their vertical orientation are displayed naturally.
    Syntax:
    text-orientation: mixed;

Example:

<!DOCTYPE html>

<html>

<head>

<style>    

div{

border: 1px solid;

font-size: 20px;

width: 250px;

height: 300px;

}

div{   

writing-mode: vertical-lr;

text-orientation: mixed;      

}

h2{

        color: tomato;

}

</style>

</head>

<body>

<h2>Example of text-orientation: mixed; </h2>

<div>

This is an example of CSS text-orientation. The example display the mixed value of this property.

</div>

</body>

</html>

Output:

Css Text Orientation

In above output, the horizontal text rotates 90oclockwise using mixed keyword of text-orientation.

  • upright:
    The characters in the horizontal orientation are set upright naturally, including the glyphs for the vertical oriented scripts. This keyword treats all the characters as left to right in the writing mode, so the value for the directionproperty is forcefully set as ltr.
    Syntax:
    text-orientation: upright;

Example:

<!DOCTYPE html>

<html>

<head>

<style>

div{

border: 1px solid;

font-size: 20px;

width: 250px;

height: 300px;

}

div{   

writing-mode: vertical-rl;

text-orientation: upright;    

}

h2{

        color: tomato;

}

</style>

</head>

<body>

<h2>Example of text-orientation: upright; </h2>

<div>

This is an example of CSS text-orientation. The example display the upright value of this property.

</div>

</body>

</html>

Output:

Css Text Orientation

Here, the above text is displayed upright from left to right using text-orientation: upright value.

  • sideways:
    This keyword sets the text in vertical writing mode sideways i.e., it allows the characters to be laid out horizontally It rotates the complete line 90o clockwise.
    Syntax:
    text-orientation: sideways;

Example:

<!DOCTYPE html>

<html>

<head>

<style>

div{

border: 1px solid;

font-size: 20px;

width: 250px;

height: 300px;

writing-mode: vertical-rl;

text-orientation: sideways;   

}

h2{

color: tomato;

width: 400px;

}

</style>

</head>

<body>

<h2>Example of text-orientation: sideways; and writing-mode: vertical-rl;</h2>

<div>

This is an example of CSS text-orientation. The example display the sideways value of this property.

</div>

</body>

</html>

Output:

Css Text Orientation

Here, the text is displayed to the sideways with the writing-mode right to left.

  • sideways-right:
    This is an alias for the sideways value, and is used for compatibility purposes.
    Syntax:
    text-orientation: sideways-right;

Example:

<!DOCTYPE html>

<html>

<head>

<style>

div{

border: 1px solid;

font-size: 20px;

width: 250px;

height: 300px;

writing-mode: vertical-lr;

text-orientation: sideways-right;

}

h2{

color: tomato;

width: 400px;

}

</style>

</head>

<body>

<h2>Example of text-orientation: sideways-right; and writing-mode: vertical-lr; </h2>

<div>

This is an example of CSS text-orientation. The example display the sideways-right value of this property.

</div>

</body>

</html>

Output:

Css Text Orientation

The output displays the text in sideways-right format.

  • use-glyph-orientation:
    This property value has been removed from use since December 2015.
    It was used with SVG elements to define SVG properties glyph-orientation-vertical and glyph-orientation-horizontal.
    glyph-orientation-horizontal is used as an alias of text-orientation.
    Syntax:
    text-orientation: use-glyph-orientation;
  • initial:
    The initial keyword assigns default value to the text-overflow property.
    Default value of text-orientation is mixed.
    Syntax:
    text-orientation: initial;

Example:

<!DOCTYPE html>

<html>

<head>

<style>

.id{

        width: 300px;

        height: 300px;

        border: 1px solid black;

        font-size: 25px;

        writing-mode: vertical-lr;

        text-orientation: initial;

}

h2{

        color: skyblue;

}

</style>

</head>

<body>

<h2>text-orientation: initial; </h2>

<div class="id">

This is an example of CSS text-orientation. The example display the initial value of this property

</div>

</body>

</html>

Output:

Css Text Orientation

Here, the script takes the initial value of the property which is mixed.

  • inherit:
    This value inherits the text-overflow property of its parent element.
    Syntax:
    text-orientation: inherit;

Example:

<!DOCTYPE html>

<html>

<head>

<style>

div {

width: 400px;

height:300px;

font-size: 15px;

border: 2px solid;

writing-mode:vertical-lr;

text-orientation: upright;

}

h2{

width: 400px;

text-orientation: inherit;

color: skyblue;

}

</style>

</head>

<body>

<h2 style="color: red">text-orientation: inherit</h2>

<div>

<h2>text-orientation: inherit derives the property of its parent element </h2>

This is an example of CSS text-orientation. The example display the inherit value of this property.

</div>

</body>

</html>

Output:

Css Text Orientation

Here the <h2> element inherits the text-orientation: upright; property of the <div> element.


Related Topics

What is CSS used for

What is CSS used for? CSS stands for Cascading Style Sheet. CSS is a stylesheet language for web pages. It specifies how a document created in a markup language looks and...

4 minutes read.

CSS Width

CSS Width The width property in CSS sets the content width of area of the element. These properties do not provide margin and border features. It is used to set the...

1 minute read.

CSS Units

CSS Units In CSS, there are so many units available to show the length’s measurement. A single unit of CSS is applied to examine the size of the property, which the...

5 minutes read.

CSS Selector

CSS Selector: There are some selectors used in CSS, which allows us to choose the content we wish to style. Various selectors are considered as the separation of the set...

5 minutes read.

CSS Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS User Interface

Introduction User Interface can be defined as series of visual elements like screens, buttons, forms that help the user interact with the software application or hardware device. CSS User Interface allows the...

6 minutes read.

CSS translate() Function

Translate() CSS function This function in CSS is a CSS in-built function. It relocates the element in the horizontal direction or in the vertical direction. It can move the items from...

2 minutes read.

CSS Overflow

CSS Overflow: The Overflow property in CSS is used to manage the content if it overflows from its container of the block level. We have seen that all the elements...

3 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

CSS Text-decoration

CSS Text-decoration: It is an essential property of CSS that is used to decorate the content of the text. It can add-on the lines above, under, and over the text....

3 minutes read.

CSS Font-Size

A Cascading Style Sheet (CSS) is a simple design scripting language intended to simplify the process of making web pages more visually appealing with the kind of high-level formatting. Cascading...

3 minutes read.

CSS Box-shadow

CSS Box-shadow This property is referred to include effects as shadow-like around an element’s frame. Syntax box-shadow: h-offset v-offset blur spread color |inset|inherit|none; Property values Following are the various property values which can be used...

3 minutes read.

CSS Math Functions

The CSS math functions permit numerical articulations. These CSS math functions can particularly be utilized in maybe unforeseen ways, for example, inside angles and shading the functions and in the...

3 minutes read.

Divi in CSS

Divi is popular WordPress themes due to its versatility and user-friendly interface. It includes a built-in page builder for sophisticated design options and an assortment of customization features to help...

9 minutes read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

Css Box Model

Introduction The Box Model property of CSS is used for design and layout of an html page. In CSS, all the elements has a rectangular box around it, you have to...

5 minutes read.

CSS Order

CSS Order CSS order property in CSS describes the flex item’s order inside the flex or any grid container. It is applied to order any flex item. Note: If any component is...

3 minutes read.

CSS Align

CSS Center Align Elements CSS center align is used to create align by using block element. You should specify margin: auto;properties. The element will take up the specified width and the remaining space....

2 minutes read.

CSS Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

CSS Zoom

CSS Zoom: Zoom property in CSS extents the content. This property controls the content’s level of magnification. Rather than the use of this CSS property, we may also apply the...

3 minutes read.