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

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 No-code customisations for Squarespace
🚀 Learn how to rank new pages on Google in 48 hours!

If you find my answer useful, 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

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 No-code customisations for Squarespace
🚀 Learn how to rank new pages on Google in 48 hours!

If you find my answer useful, 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.

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 No-code customisations for Squarespace
🚀 Learn how to rank new pages on Google in 48 hours!

If you find my answer useful, 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.