The Wayback Machine - https://web.archive.org/web/20250401075117/https://www.geeksforgeeks.org/css-text-transform-property/
Open In App

CSS text-transform Property

Last Updated : 01 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The text-transform property in CSS is used to control the capitalization of text. It allows you to transform text to uppercase, lowercase, or capitalize the first letter of each word.

Syntax

text-transform: none| capitalize | uppercase | lowercase |initial | inherit; 

Property Values

Here are the property values for the text-transform CSS property:

ValueDescription
noneDefault value. No capitalization.
capitalizeTransforms the first character of each word to uppercase.
uppercaseConverts all characters in each word to uppercase.
lowercaseConverts all characters in each word to lowercase.
initialSets the property to its default value.

CSS text-transform Property Example

Here are some examples of the CSS text-transform property that will help you clearly understand how it works:

Example 1: Using text-transform: none;

In this example we are using the text-transform: none; property to display text in its original form without any capitalization changes. It demonstrates the default text transformation behavior in a paragraph.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-transform Property
    </title>
    <style>
        h1 {
            color: green;
        }

        p.gfg {
            text-transform: none;
        }
    </style>
</head>

<body>

    <h1>GeeksForGeeks</h1>

    <h2>text-transform: none:</h2>
    <p class="gfg">GeeksforGeeks</p>


    <p class="gfg">
        It is a computer science portal for geeks.
    </p>
</body>

</html>

Output: 

Example 2: Using text-transform: capitalize;

In this example we are using the text-transform: capitalize; property to transform the first letter of each word to uppercase. It demonstrates this effect on paragraphs styled with the gfg class.

html
<!DOCTYPE html>
<html>
  
<head>
    <title>
        CSS text-transform Property
    </title>
    <style>
        h1 {
            color: green;
        }

        p.gfg {
            text-transform: capitalize;
        }
    </style>
</head>

<body>
    <center>
        <h1>GeeksForGeeks</h1>

        <h2>text-transform: capitalize:</h2>
        <p class="gfg">GeeksforGeeks</p>
        <p class="gfg">
            It is a computer science portal for geeks.
        </p>
    </center>

</body>
  
</html>

Output: 

Example 3: Using text-transform: uppercase;

In this example we are using text-transform: uppercase; property to convert all characters in the paragraphs with the gfg class to uppercase. The heading remains in its original form.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-transform Property
    </title>
    <style>
        h1 {
            color: green;
        }

        p.gfg {
            text-transform: uppercase;
        }
    </style>
</head>

<body>
    <h1>GeeksForGeeks</h1>

    <h2>text-transform: uppercase:</h2>
    <p class="gfg">GeeksforGeeks</p>
    <p class="gfg">
        It is a computer science portal for geeks.
    </p>

</body>

</html>

Output: 

Example 4: Using text-transform: lowercase;

In this example we are using text-transform: lowercase; property to convert all characters in the paragraphs with the gfg class to lowercase. The headings remain in their original form.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-transform Property
    </title>
    <style>
        h1 {
            color: green;
        }

        p.gfg {
            text-transform: lowercase;
        }
    </style>
</head>

<body>

    <h1>GeeksForGeeks</h1>

    <h2>text-transform: lowercase:</h2>
    <p class="gfg">GeeksforGeeks</p>
    <p class="gfg">
        It is a computer science portal for geeks.
    </p>

</body>

</html>

Output: 

Example 5: Using text-transform: initial;

In this example we are using the the text-transform: initial; property to set the text transformation to its default value for paragraphs with the gfg class. The headings remain unchanged.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-transform Property
    </title>
    <style>
        h1 {
            color: green;
        }

        p.gfg {
            text-transform: initial;
        }
    </style>
</head>

<body>

    <h1>GeeksForGeeks</h1>

    <h2>text-transform: initial:</h2>
    <p class="gfg">GeeksforGeeks</p>


    <p class="gfg">
        It is a computer science portal for geeks.
    </p>
</body>

</html>

Output: 

Supported Browsers

The browser supported by CSS Text-Transform property are listed below: 

Note: Older versions of these browsers may not support all CSS properties, so it’s always a good practice to test your styles across different browsers for compatibility.

CSS text-transform Property – FAQs

What does the text-transform property in CSS do?

The text-transform property in CSS controls the capitalization of text. It can convert text to uppercase, lowercase, or capitalize the first letter of each word, providing style flexibility without altering the HTML content.

How can I make text uppercase using CSS?

To make text uppercase, use: text-transform: uppercase;. This converts all the text in the element to uppercase letters.

What are the possible values for text-transform?

The possible values for text-transform are none, capitalize, uppercase, and lowercase. Each value transforms the text differently.

Does text-transform affect non-alphabetic characters?

No, text-transform only affects alphabetic characters. Non-alphabetic characters, such as numbers or punctuation marks, remain unchanged.

Can text-transform be animated?

Text-transform cannot be directly animated, but you can create animations by transitioning between styles with different text-transform values.



Next Article

Similar Reads

three90RightbarBannerImg