CSS Properties
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.
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
Value | Description |
---|---|
none | No transformation is applied. The text is displayed normally. |
capitalize | Transforms the first character of each word to uppercase. |
uppercase | Transforms all characters to uppercase. |
lowercase | Transforms all characters to lowercase. |
full-width | Transforms 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.
<!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:
Author
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
If you have any doubts regarding this article (CSS text-transform Property), please comment here. I will help you immediately.