Heo Posted June 30, 2025 Posted June 30, 2025 Problem: SplitText doesn't split by lines, when I have nested tag in it. See the Pen xbGeRMM by lovesossa (@lovesossa) on CodePen.
Solution mvaneijgen Posted June 30, 2025 Solution Posted June 30, 2025 Hi @Heo welcome to the forum! Your .h2 is not the parent element of the text, I you split on the <p> which is the parent element with all the text it works as expected. Hope it helps and happy tweening! See the Pen pvJBRjV by mvaneijgen (@mvaneijgen) on CodePen. 3
Heo Posted June 30, 2025 Author Posted June 30, 2025 @mvaneijgen Oh, I see, thank you very much. I think there should be automatic detection of nested tags, as there can be any number of <p> from CMS
Rodrigo Posted June 30, 2025 Posted June 30, 2025 Yeah that's a little bit more tricky actually because of where you stop looking for nested elements. In your demo, for example, you have a nested <em> inside the element you want to split, but how should SplitText know where to stop? See the problem? This could mean that in similar cases (like yours) users could complain: "I didn't wanted for SplitText to do that and split what's inside the <em> or <strong> tags". Finding a way to achieve all of that could be expensive in terms of KB and is not something that is widely requested by users. If there is enough traction for it we could evaluate adding it, but in the short/mid term there are no plans for it. Finally, regardless using a CMS or coding the HTML directly, is always a good idea to have the biggest possible control over the HTML structure in order to be able to point for the target elements with a selector as specific as possible. Happy Tweening!
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