Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS text-transform Property

Posted in CSS Tutorial
Updated on Oct 13, 2024
By Mari Selvan
👁️ 24 - Views
⏳ 4 mins
💬 1 Comment
CSS text-transform Property

Photo Credit to CodeToFun

🙋 Introduction

The text-transform property in CSS allows you to control the capitalization of text. It can transform text to uppercase, lowercase, or capitalize each word, making it a versatile tool for text formatting in web design.

This property is useful for ensuring consistency in the appearance of text, regardless of how it is entered by users or stored in a database.

💡 Syntax

The syntax for the text-transform property is simple. It can be applied to any text element.

Syntax
Copied
Copy To Clipboard
element {
  text-transform: value;
}

🎛️ Default Value

The default value of the text-transform property is none, which means the text is displayed as it is entered or stored.

🏠 Property Values

ValueDescription
noneNo transformation is applied. The text is displayed normally.
capitalizeTransforms the first character of each word to uppercase.
uppercaseTransforms all characters to uppercase.
lowercaseTransforms all characters to lowercase.
full-widthTransforms characters to their full-width form, typically used in East Asian typography (not supported in all browsers).

📄 Example

In this example, we'll apply different text transformations to paragraphs.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS text-transform Example</title>
  <style>
    .none {
      text-transform: none;
    }
    .capitalize {
      text-transform: capitalize;
    }
    .uppercase {
      text-transform: uppercase;
    }
    .lowercase {
      text-transform: lowercase;
    }
  </style>
</head>
<body>
  <h1>Text Transformations</h1>
  <p class="none">This text is not transformed.</p>
  <p class="capitalize">this text is capitalized.</p>
  <p class="uppercase">this text is uppercase.</p>
  <p class="lowercase">THIS TEXT IS LOWERCASE.</p>
</body>
</html>

🖥️ Browser Compatibility

The text-transform property is widely supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It works reliably across different platforms and devices, making it a dependable tool for text formatting.

🎉 Conclusion

The text-transform property is a useful feature in CSS for controlling the capitalization and formatting of text on your web pages.

Whether you need to standardize the appearance of user-generated content or enhance the readability of your text, text-transform offers a straightforward solution. Experiment with different values to see how they can improve the look and feel of your text.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy