Open In App

How to Transform Text to Uppercase in CSS?

Last Updated : 29 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To transform text to uppercase in CSS, you can use the text-transform property. This property allows you to control the capitalization of text visually, without altering the original content in the HTML markup.

By setting text-transform: uppercase; all text within the specified HTML element will display in uppercase, making it ideal for emphasizing headings or important sections

Convert Text to Uppercase using text-transform Property

The text-transform property is used to specify how to capitalize or format text. To convert text to uppercase, set the value of text-transform to uppercase.

Example 1: In this example, we will convert text to Uppercase using the text-transform property.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>Uppercase Text</title>
    
    <style>
        .uppercase-text {
            text-transform: uppercase;
        }
    </style>
</head>

<body>
    <p class="uppercase-text">
        This text will be displayed in uppercase.
    </p>
</body>

</html>

Output:

THIS TEXT WILL BE DISPLAYED IN UPPERCASE.

Additional text-transform Values

The text-transform property supports various values to control the appearance of text:

  • uppercase: Converts all characters in the text to uppercase.
  • lowercase: Converts all characters in the text to lowercase.
  • capitalize: Capitalizes the first letter of each word, which is useful for styling titles or headings in a sentence case format.
  • none: Disables text transformation, displaying text in its original form

Conclusion

The text-transform property is a simple yet powerful tool for managing text appearance in CSS. With values like uppercaselowercase, and capitalize, you can easily style text to fit your design needs without altering the HTML content itself. Use text-transform: uppercase; for bold headings, or text-transform: capitalize; to achieve a more natural look by capitalizing the first letter of each word. This property helps maintain a clean and organized HTML structure while providing flexibility in text presentation


Similar Reads