div.c {
text-transform: capitalize;
}
<html>
<body>
<h2>text-transform: capitalize:</h2>
<div class="c">Hi THis is TEST teXT</div>
</body>
</html>
Try this.
div.c {
text-transform: capitalize;
}
<html>
<body>
<h2>text-transform: capitalize:</h2>
<div class="c">Hi THis is TEST teXT</div>
</body>
</html>
Try this.
In Javascript:
function titleCase(str) {
var splitStr = str.toLowerCase().split(' ');
for (var i = 0; i < splitStr.length; i++) {
// You do not need to check if i is larger than splitStr length, as your for does
that for you
// Assign it back to the array
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
}
// Directly return the joined string
return splitStr.join(' ');
}
document.write(titleCase("I'm a little tea pot"));
Please see Capitalize First Letter Of Each Word In A String – JavaScript
You can use the following if you strictly want to do it in style.css file:
selector{
text-transform: capitalize;
}
Another option is :
{{ textToBeConverted | uppercase }}
Thanks !
Angular has a inbuilt pipe for this
{{name | titlecase}}
link
What you want is impossible using pure CSS. Please refer to this answer.
Alternative, you can use it with angular lowercase pipe and titlecase pipe:
{{ textToTransform | lowercase | titlecase }}
My database give mixed font styles, for Example:
” Hi THis is TEST teXT “
I want to capitalization this type of fonts. I found a way, first using lowercase and then ::first-letter
to be capitalized. This give the first letter only capital.
But I want capitalization in every first word, is there any way?
angular.io/api/common/TitleCasePipe
I want only in style css, without using angular.
“But i want capitalization in every first word” .. First word or first letter on each word??
Yes its possible in css.. You can add this for example, h5 {text-transform: lowercase;}
Please
it is not fixed my scenario.
@Sahin
Not working, i already checked.
no java scripts only css
Using css, is possible ? Please understand the scenario
Oh I get it. Your data is in mixed form. Why don’t you use the second option using pipe {{ textToBeConverted | uppercase }}
Our side is large number of data, so can’t using angular functions, bit slow, and next reason is we dont go with dev side, using client side is better to formatting.
Honestly it isn’t so slow that it would make a difference to the user. The data rendered would not take hefty amount of time.I work with huge data set and using pipes never made a problem.
Ohh ok, but we have some issues regarding this, thats why.
Using angular this is a way i know, but using css i want
oh ok let me check
with your reference link, they posted “cant do this with pure CSS”. but using angular pipe will do right. i want to try using pure css, thats why i created a new ticked.