×

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

How To Use CSS

You can use CSS(Cascading Style Sheet) in four ways. These are given below: The given above CSS type, in which various technique will be used. These are different from each other and...

2 minutes read.

How to create blinking text using CSS

The blinking effect is used in HTML and CSS to take the attraction towards a particular word or section. If you need such a blinking effect, we need to take...

2 minutes read.

How to center a table in CSS

The table is used to store and arrange the data in tabular format. The data here can be of any form like text, image, links, etc. The table is made...

3 minutes read.

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The...

8 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS Pseudo-class

Pseudo-class The pseudo-class may be depicted as the keyword which can be mixed to any selector that specifies the elected element’s unique state. It can be included to a selector to...

6 minutes read.

CSS Functions

CSS functions are used for different CSS properties. Every front-end developer should have knowledge of all CSS functions. It makes the coding easier. FunctionsExplanationattr().It returns the value of an attribute of...

5 minutes read.

CSS Variables

CSS Variables These variables of CSS are applied to add the custom property values to our various web-pages. The custom properties are often called as CSS variables or cascading variables. Various...

4 minutes read.

CSS Display

CSS Display: The CSS Display property is one of an essential property among all other properties of CSS. The display property specifies how the HTML elements should be displayed on...

4 minutes read.

CSS Superscript and Subscript

Superscript and Subscript To specify the superscript and the subscript text, HTML provides us two tags that are <sup> and <sub>. The superscript content looks in the shorter font and half...

2 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.

Grid Vs Flexbox in CSS

Grid: - CSS Grid Layout is a 2D grid-based matrix-based layout method with columns and rows that simplifies web pages created by eliminating the need for floats and placement. A grid layout, like...

4 minutes read.

CSS Flex-Box

Introduction The flex-box property of CSS stands for Flexible Box Layout Module. It is specifically used to design a flexible responsive layout. Flex-box is a one dimensional layout model, i.e. it works...

6 minutes read.

CSS White Space Property

White Space in CSS The white-space CSS property describes how to show the content inside an element. This property is applied to manage a white space within an element. Values of White-space...

2 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 Tutorial

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

9 minutes read.

CSS Inline

What is CSS? CSS is an acronym for Cascading Style Sheets. CSS is the language that we use to style an HTML document. It specifies how HTML components should appear. CSS...

4 minutes read.

Difference between HTML and CSS

HTML HTML stands for HyperText Markup Language and is used to create web pages and websites and web applications, which means we can create static web pages. Html is a scripting...

3 minutes read.

CSS Background-blend-mode

Background-blend-mode The background-blend-mode property sets a blend mode of the component’s every background layer (color/image). It illustrates how the element background image blends well with the element background color. We can...

9 minutes read.