GHazelwood Posted August 14, 2025 Posted August 14, 2025 Hey everyone, hope you're all well? Long story short, I need my headings to have the first letter capitalised automatically. Splittext overrides this and my headings default to all lowercase. e.g. .heading-style-h1::first-letter { text-transform: uppercase; } Is there a setting in split-text where I can make the first letter capitalised, or keep the styling? First time posting and a GSAP newbie so please be gentle! Thanks so much.
Rodrigo Posted August 14, 2025 Posted August 14, 2025 Hi @GHazelwood and welcome to the GSAP Forums! Because of the way SplitText works it wraps every character around a <div> tag (this allows you to create cool transform animations among other things) so there are no letters inside the <h1> just divs. You can solve this using the charsClass config option in order to give each character a class and point the first child of that class inside of an <h1>, or create a more global selector to apply the text transform to the first div child of the h1, something like this: h1::first-letter, h1 .title-character:first-child, h1 div:first-child { text-transform: uppercase; } Here is a simple demo: See the Pen OPyzPxO by GreenSock (@GreenSock) on CodePen. Hopefully this helps Happy Tweening! 1
GHazelwood Posted August 19, 2025 Author Posted August 19, 2025 Hi @Rodrigo this is awesome, thanks so much. And really appreciate the speedy response! Apologies for the delay my side, I've been away. I'm only looking to make the first letter of the first word a caps - I've had a crack at implementing here: https://the-off-switch.webflow.io/services/irritable-bowel-syndrome but it's gone a little haywire and is capitalising the entire first word. Looking at documentation, would this be something to do with "class="char char1"?
Rodrigo Posted August 20, 2025 Posted August 20, 2025 Then just use a single element for the whole sentence, the CSS and the JS is the same, here is a fork of the demo: See the Pen jEbzBpY by GreenSock (@GreenSock) on CodePen. Another alternative with the original demo I posted is to get fancy with the CSS selectors: h1:first-child::first-letter, h1:first-child .title-character:first-child, h1:first-child div:first-child { text-transform: uppercase; } That's just a couple of options, there might be others but these use CSS. Hopefully this helps Happy Tweening!
Solution Cassie Posted August 20, 2025 Solution Posted August 20, 2025 You can also add numbered classes and just target the specific class. That's probably the easiest route! .char1 { text-transform: uppercase; } SplitText.create(e, { type: "chars", charsClass: "char++" }); See the Pen VYvXQrp?editors=1111 by GreenSock (@GreenSock) on CodePen. 1
GHazelwood Posted August 20, 2025 Author Posted August 20, 2025 Thanks @Rodrigo, it was still misbehaving due to me using a class called ".split" to split up the letters - my settings were slightly different to yours which was making it go nuts (I was following a Webflow tutorial which is probably why). Huge thanks @Cassie, I've applied the numbered characters and that's done the trick, hugely appreciate everyone's help. Looking forward to Webflow Conf too!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now