Jump to content

Underline Page Title Word(s)

Recommended Posts

1 hour ago, SSchulze said:

Site URL: https://www.infinix.com/landing

Hello,

I am trying to underline two words in a page title but can't seem to make it work.  The page title for the page is "How to Make Secondary Caries Go Away!"  I want to underline the "Go Away!" part only.

https://www.infinix.com/landing

Thank you,

Stephanie

You can add to Home > Settings > Advanced > Code Injection, choose the footer

<script>
    (function(){
        /*separate Go Away title*/
        document.addEventListener('DOMContentLoaded',()=>{
            const pageTitle = document.querySelector('#page-title');
            const titleWords = pageTitle.textContent.split(' ');
            const strongWord = titleWords.slice(titleWords.length - 2).join(' ');
            const normWord = titleWords.slice(0, titleWords.length - 2).join(' ');
            const htmlPageTitle = `<span class="normal-title">${normWord}</span> <span class="strong-title">${strongWord}</span>`;
            pageTitle.innerHTML=htmlPageTitle;
        });
    })();
</script>

<style>
    /*style for Go Away title*/
    #page-title .strong-title {
        text-decoration: underline;
    }
</style>

Let me know how it works on your site

Support me by pressing 👍 if this useful for you

Edited by bangank36

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

My testing result

image.thumb.png.fc2da509a12e451aa6de122da0af3754.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

You can delete this row or update my previous code

image.png.c47ab72ddbe8821751f54f192bfb6ac3.png

It 's just the result when i tested in  console.

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.