sabiut
July 30, 2019, 5:06am
1
How do I capitalize the first letter of the span tag? for instance, if I have the HTML code, how do I capitalize all the first letter of the span tag using javascript
<div id="Header">
<h1>
<img height="150" src="http://test.com/im.jpeg">
<span>test</span> <span>test1</span> <span>test2</span>
</h1>
</div>
kruxor
July 30, 2019, 5:12am
2
you can do this with css
#Header span {
text-transform:capitalize;
}
2 Likes
You can use span as a selector and use text-transform property for formating letters.
<style>
span{
text-transform:capitalize;
}
</style>
sabiut
July 30, 2019, 11:01am
5
I know this could be done with css. but i want to do it with javascript
Hey!
You can make a function like this:
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
1 Like
Hi,could you please tell me ,how to call the function in h1 tag