I’m currently working on a project where I’ve applied the text-transform: capitalize;
property to a specific class (div.c
), but it doesn’t seem to be working as expected when the text is in all capital letters.
Here’s a snippet of the code:
<!DOCTYPE html>
<html>
<head>
<style>
div.c {
text-transform: capitalize;
}
</style>
</head>
<body>
<h2>text-transform: capitalize:</h2>
<div class="c">THIS IS TESTING CONTENT</div>
</body>
</html>
3
Answers
We can’t apply
capitalize
when all letter are inuppercase
You can almost do it with:
OR
You can also do it with JavaScript
When you set text-transform: capitalize;, it capitalizes the first letter of each word in the text.
if you have pre-written the text in capital letter than that "capitalize" will have no effect.
span,
a,
h2{
text-transform:lowercase
}
span:first-letter, a:first-letter, h2:first-letter
{
text-transform: capitalize;
}