Connect with us

CSS

Which CSS Property Configures the Capitalization of Text?

Spread the love

When styling text in CSS, you may want to control capitalization to improve readability or maintain consistency in design. The CSS property used for this purpose is text-transform.

In this blog, we’ll cover:
✅ What text-transform does
✅ Different values of text-transform
✅ Examples of capitalization styles
✅ Best practices for using text-transform

1. Understanding text-transform

The text-transform property controls the capitalization of text. It allows you to:

  • Convert text to uppercase or lowercase
  • Capitalize the first letter of each word
  • Control text casing automatically without modifying the HTML content

2. Values of text-transform

1. uppercase (Converts all letters to uppercase)

h1 {
    text-transform: uppercase;
}
<h1>Welcome to My Website</h1>

Output:
👉 WELCOME TO MY WEBSITE

✅ Useful for making headings and titles stand out.


2. lowercase (Converts all letters to lowercase)

p {
    text-transform: lowercase;
}
<p>THIS IS A PARAGRAPH.</p>

Output:
👉 this is a paragraph.

✅ Ideal for cases where uniform lowercase text is required.


3. capitalize (Capitalizes the first letter of each word)

h2 {
    text-transform: capitalize;
}
<h2>hello world</h2>

Output:
👉 Hello World

✅ Useful for formatting titles and proper names automatically.


4. none (Removes any text transformation)

span {
    text-transform: none;
}

✅ Resets text formatting if an inherited style applies uppercase or capitalize.


3. Full Example: Applying text-transform to Different Elements

h1 {
    text-transform: uppercase;
}

p {
    text-transform: lowercase;
}

h2 {
    text-transform: capitalize;
}
<h1>this is a heading</h1>
<p>THIS TEXT WILL BE LOWERCASE.</p>
<h2>welcome to my blog</h2>

Output:

  • THIS IS A HEADING
  • this text will be lowercase.
  • Welcome To My Blog

4. Best Practices for Using text-transform

Use text-transform instead of modifying text manually – This keeps your HTML clean and easy to manage.
Avoid capitalize for sentence-based text – It only capitalizes the first letter of each word, even in cases where it shouldn’t (e.g., “the Quick brown Fox”).
Pair with font-variant for small caps – If you want small capital letters, use font-variant: small-caps;.


5. Conclusion

The text-transform property is a powerful tool in CSS for controlling text capitalization. It allows you to convert text to uppercase, lowercase, or capitalized format without modifying the original content.

Quick Recap:

uppercase → Converts all letters to UPPERCASE
lowercase → Converts all letters to lowercase
capitalize → Capitalizes Each Word’s First Letter
none → Keeps text in its original format

By using text-transform, you can ensure consistent text formatting across your website, improving both design and readability.


Spread the love
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *