Jump to content

How to ADD underlines to all nav links?

Recommended Posts

Hi peeps, long-time reader, first first-time poster here,

I have a long-form content page with the header navigation comprised of "page jump" anchor links. The client is a bit old school and would like ALL the links in the nav to be underlined - all of the time. I've tried using some simple CCS rules, but they didn't work. Since I'm a total rookie at CSS, I'm guessing I'm probably missing something basic. Any help would be VERY appreciated, especially since this is the last thing on my punch list for handing the site off to the client.

Here's the CSS I tried without success:

.nav-menu a {
  text-decoration: underline;


.nav-menu a {
    border-bottom: 2px solid;



Edited by peterw
Link to comment
  • peterw changed the title to How to ADD underlines to all nav links?

Solved by Chat GTP!

Settings" >>> "Advanced" >>> "Code Injection."
In the "Footer" section, paste the JavaScript code wrapped inside the <script> tags.
Save your changes and close the Code Injection panel.
Preview or publish your site to see the underlined links in the site navigation menu.

document.addEventListener('DOMContentLoaded', function() {
  var navLinks = document.querySelectorAll('.header-nav-item a');
  for (var i = 0; i < navLinks.length; i++) {
    navLinks[i].style.textDecoration = 'underline';

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.