Change color of all hyperlinks

Hey guys, In this post, I explain how to change the color of all hyperlinks at once

Go to Dashboard → Settings. Scroll down to the Advanced section → Custom Code, and then click the +Add Custom Code button.
Please note - The site needs to be Premium to add Custom Code.

Paste the following code snippet and select All Pages or choose a specific page.
The body should be at the Body - End.

<script>
  
colorLinks("#0645AD"); //Change with your favorite color

function colorLinks(hex)
{
    var links = document.getElementsByTagName("a");

    for(var i=0;i<links.length;i++)
    {

            links[i].style.color = hex;  
  
    }  
}
</script>

WALLA! all the hyperlinks will change to blue

2 Likes

Good one!

Wow, thank you! I have spent hours looking for something like this!!

Why isn’t this a native feature part of wix? It’s a common standard to have links of same style throughout the site and there should be an inbuilt feature to do this.

1 Like

Wix is constantly working on improving the developer experience. Feel free to make your voice heard. The Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.

This was so easy - to be honest I was a bit scared to do it - but it works great!
If only it worked for the side sections as well… Thank you so much @binyaminm

@ileanacastrillo happy to help:)
What do you mean by side section? Can you share a screenshot?

@binyaminm Sure! Here it is


Because it was the only one on this column I just manually changed the color but - just to double-check I went back into the editor and changed it back and now it works just fine!
I’m wondering if it was just a slight delay and I was only being a little impatient?

Since you’re already here though :wink:
Can I ask - why is there so much empty space on the blog post preview itself? I tried making it smaller but it won’t let me and I don’t see an option for getting it to include more text in the space available… Any thoughts? Thanks so much for your help and your prompt reply!

Unfortunately this is only possible if the user accepts cookies! Which is very weird! I wonder why wix developers haven’t thought this through.

Alternatively I would make a request to be able to select hyperlinks using $w() which is currently not possible whatsoever!

Actually, this is not true. If you set it as “essential” it doesn’t need to be accepted.

@ajanistella Well, the problem is, I have two scripts, one that adds analytics and the other is essential. Unfortunately, I can only add one custom code before the end of the body. But wix does not allow to add two custom snippets before the end of the body. Do you understand me?

The user has the right to refuse all cookies, even the essential ones. So it wouldn’t work anyway! Features like styling a link should simply not be this complicated! I would seriously urge wix product designers to consider giving this a second shot!

I’ve made a request here https://www.wix.com/velo/forum/site-page-design/request-ability-to-select-hyperlinks-using-w Feel free to vote it up and urge wix team to design/develop this better!

How do I remove the underline by default for the links?

@madhu Gotcha. Sorry, I’m not an expert at any of this. Yeah, that makes sense, I agree.

That’s not how a request is made, you should submit an actual request through the request feature.

@ajanistella where can I do that?! I cannot find this on the velo forum!

@madhu huh they seem to have gotten rid of it since the switch to Velo. Ugh. Consider submitting a support ticket via email and then they might direct you to submit a formal request.

I consider this a hack, this is not an elegant way of doing things. Being a developer one should know! and the product should add this feature properly, I can’t believe they are suggesting everyone to do this hack! Sigh!

Unfortunately it didn’t work for me :frowning:
Does it matter if the code is placed in “head” or “body”?

this should be part of the “theme manager” and seems like a very basic function that is missing.

Come on Wix…