CSS text-transform property for Uppercase and LowerCase and TitleCase

CSS text-transform property for Uppercase and LowerCase and TitleCase

In this tutorial, we’ll learn how we can change the element’s text into uppercase, lowercase and titlecase using text-transform property.

CSS has text-transform property to control the text capitalization.

Firefox takes language into consideration. You can learn more about here: CSS Text Transform

In this article, we’ll see how can we use css text-transform property value to capitalize the first letter of word, to convert all letters into uppercase(All cap), to convert all letters into lowercase.

We’ll also see an advanced example to capitalize the first letter of a sentence.

text-transform

text-transform property can have the following 6 values for managing text:

lowercase: It changes all letters into lowercase.

uppercase: It changes all letters into uppercase.

capitalize: It changes each word’s first letter in a capital letter.

none: It is the default value, and it keeps the value as it is entered.

inherit: Inherit this property form the parent element.

In all following example, we’ll take the following HTML markup into consideration.
<br />&lt;p&gt; This is an example of css lowercase. &lt;/p&gt;<br />

lowercase – How to change all letters into lowercase.

Input : This is an example of css lowercase.
Code:

<br />p {<br />&nbsp; text-transform: lowercase;<br />&nbsp;}<br />

Output : this is an example of css lowercase.

uppercase – How to change all letters into uppercase.

Input : This is an example of css uppercase.
Code:

<br />p {<br />&nbsp; text-transform: uppercase;<br />&nbsp;}<br />

Output : THIS IS AN EXAMPLE OF CSS UPPERCASE.

capitalize – How to capitalize the first letter of each word.

Input : This is an example of css capitalize
Code:

<br />p {<br />&nbsp; text-transform: capitalize;<br />&nbsp;}<br />

Output : This Is An Example Of Css Capitalize.

none – It doesn’t change any value.

Input : This is Elite corner ARTICLE
Code:

<br />p {<br />&nbsp; text-transform: none;<br />&nbsp;}<br />

Output : This is Elite corner ARTICLE

capitalize the first letter of a sentence.

If you want to capitalize only the first letter of a sentence instead of capitalizing the first letter of all words of a sentence, you’ll need to use css pseudo selector called :first-letter

Input : this is an article about css text-transform property to capitalize only the first letter of a sentence.
Code:

&lt;p class="sentence"&gt;<br />this is an article about css text-transform property <br />to capitalize only the first letter of a sentence.<br />&lt;/p&gt;<br />
.sentence:first-letter {<br /> text-transform: capitalize;<br />}
Output : This is an article about css text-transform property to capitalize only the first letter of a sentence.

I hope you like this article.
Also, read:

Share with your friends if you like this post.

Leave a Comment