You are currently viewing CSS: Text-Combine-Upright – Specifying Text Glyph Orientation

CSS: Text-Combine-Upright – Specifying Text Glyph Orientation

CSS offers a variety of properties that allow developers to control text appearance and layout, enabling the creation of visually appealing and readable content. One of these properties is text-combine-upright, which is particularly useful in vertical writing modes, such as in Japanese and other East Asian scripts. This property allows multiple characters to be combined and displayed upright within a single glyph space, facilitating more compact and aesthetically pleasing text layouts.

The text-combine-upright property in CSS is used to specify how text glyphs should be combined and displayed upright within vertical text layouts. This can be particularly beneficial for creating vertical text arrangements, such as in East Asian typography, where combining characters within a single glyph space can improve readability and design. In this article, we will explore the text-combine-upright property in depth, providing examples and explanations to help you effectively use it in your web projects.

Understanding the text-combine-upright Property

The text-combine-upright property in CSS is used to combine multiple characters into a single glyph in vertical writing modes. It accepts several values:

  • none: This is the default value, where text is not combined.
  • all: Combines all characters within the element, displaying them upright.
  • digits: Combines digits within the element, displaying them upright.

Using the text-combine-upright property, you can control how text is displayed in vertical writing modes, improving the visual presentation of text in certain languages and contexts.

Basic Setup

To demonstrate the text-combine-upright property, we will create a simple HTML structure and apply different values to it.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Text-Combine-Upright Example</title>

    <style>

        .vertical-text {
            writing-mode: vertical-rl;
            text-orientation: upright;
            border: 1px solid #ccc;
            padding: 10px;
            width: 100px;
        }

        .combine-none {
            text-combine-upright: none;
        }

        .combine-all {
            text-combine-upright: all;
        }

        .combine-digits {
            text-combine-upright: digits;
        }

    </style>

</head>
<body>

    <h1>CSS Text-Combine-Upright Example</h1>

    <div class="vertical-text combine-none">
        <p>1234 ABCD</p>
    </div>

    <div class="vertical-text combine-all">
        <p>1234 ABCD</p>
    </div>

    <div class="vertical-text combine-digits">
        <p>1234 ABCD</p>
    </div>

</body>
</html>

In this setup, we define three different classes (combine-none, combine-all, combine-digits) each applying a different text-combine-upright value. Each paragraph demonstrates how text is combined and displayed within a vertical writing mode.

Practical Examples of text-combine-upright

Example 1: None

The default behavior is to not combine any characters, allowing text to flow naturally within the vertical layout.

<div class="vertical-text combine-none">
    <p>1234 ABCD</p>
</div>

In this example, the combine-none class sets text-combine-upright to none, ensuring that each character is displayed separately within the vertical text layout.

Example 2: All

Combining all characters within the element can create a more compact and visually appealing arrangement.

<div class="vertical-text combine-all">
    <p>1234 ABCD</p>
</div>

Here, the combine-all class sets text-combine-upright to all, combining all characters into a single glyph space. This can be particularly useful for creating compact vertical text arrangements in East Asian typography.

Example 3: Digits

Combining only the digits within the element can be useful for scenarios where numeric data needs to be displayed more compactly.

<div class="vertical-text combine-digits">
    <p>1234 ABCD</p>
</div>

The combine-digits class sets text-combine-upright to digits, ensuring that only the digits are combined and displayed upright. This approach can enhance the readability and presentation of numeric data within vertical text layouts.

Combining text-combine-upright with Other CSS Properties

The text-combine-upright property can be combined with other CSS properties to create more complex and visually appealing text layouts. For example, combining text-combine-upright with properties like font-size, color, and letter-spacing can help achieve the desired look and feel for your vertical text content.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Text-Combine-Upright Example</title>

    <style>

        .combined-style {
            writing-mode: vertical-rl;
            text-orientation: upright;
            text-combine-upright: digits;
            font-size: 1.5em;
            color: #333;
            letter-spacing: 2px;
            padding: 10px;
            border: 1px solid #000;
            width: 100px;
        }

    </style>

</head>
<body>

    <h1>CSS Text-Combine-Upright Example</h1>

    <div class="combined-style">
        <p>5678 EFGH</p>
    </div>

</body>
</html>

In this example, we create a class named combined-style that applies text-combine-upright to combine digits, along with additional font, color, and spacing styling. This demonstrates how text-combine-upright can be part of a larger set of styles to enhance the presentation of vertical text.

Conclusion

The text-combine-upright property in CSS is a valuable tool for controlling the orientation and combination of text glyphs within vertical writing modes. By understanding and effectively utilizing this property, you can create visually appealing and readable web pages that accommodate different writing systems and design requirements. Whether you need to combine all characters or just digits, the text-combine-upright property offers the flexibility to achieve your desired text layout.

In this article, we explored the various values of the text-combine-upright property, provided practical examples, and demonstrated how to combine it with other CSS properties for enhanced styling. Mastering text glyph orientation is a fundamental skill for web designers and developers, enabling you to create balanced and professional web content suitable for diverse audiences and languages.

Leave a Reply