educational

Multiple Link Colors with CSS

Software Used: Notepad (or any HTML editor)
Skill Level: Intermediate

I like to spend a couple of hours a day reading through industry news and networking with other designers or webmasters to generate ideas within the business. Not only can I find out the latest scoop on important industry issues, I can also look at what questions most people have pertaining to specific developer programs and languages. While I was browsing the boards today, an interesting question arose regarding the possibility of having more than one set of colors for links within HTML. The only viable option that we can use to implement this is through the application of pseudo-classes in CSS (Cascading Style Sheets).

I've been using CSS for almost as long as I've been designing. It's great for the simple reason that it grants the author and reader more control over the viewing of a site. When I first started using it, I thought CSS only allowed text to be a fixed size, style and color; soon I was using it to add color to my forms and scrollbars. Today I realize that CSS can be used to make a site look good at any resolution with relative positioning, or it can cut down the file-size of a block of formatted HTML by a third and so very much more. But you wanted to know about having more than one text-link color, didn't you...

N.B. This tutorial is written with the assumption that you know the bare basics of CSS & HTML.

1. Start by making a blank html page and opening it within your editor. Add a title and make the background color white to begin with:

<title>CSS Test</title>
<body bgcolor="#FFFFFF">

2. Add the CSS into the head of the HTML which will tell the browser what colors the links will be in their various states. I've opted for the default blue, red and purple colors you find on most sites:

<title>CSS Test</title>
<style>
  a.link { color:#0000FF }
  a.active { color:#FF0000 }
  a.visited { color:#660099 }
  a.hover { color:#FF0000 }
</style>
<body bgcolor="#FFFFFF">

This will make all the links appear blue within the browser. When the link is active or the cursor is over it, the color will change to red. Visited links will appear purple. However, this applies to all links on this page. Anything from a text link to an image with a border. So now we need to make two separate sets of colors.

3. Add a small name to your first set of text links. This name needs to be inserted within each style, between the 'a.' and the link-state. I opted for the name 'text1' for simplicity:

<title>CSS Test</title>
<style>
  a.text1:link { color:#0000FF }
  a.text1:active { color:#FF0000 }
  a.text1:visited { color:#660099 }
  a.text1:hover { color:#FF0000 }
</style>
<body bgcolor="#FFFFFF">

4. Now make a second set of link colors with a different name. I chose 'text2' to have the colors green, orange and light blue.

<title>CSS Test</title>
<style>
  a.text1:link { color:#0000FF }
  a.text1:active { color:#FF0000 }
  a.text1:visited { color:#660099 }
  a.text1:hover { color:#FF0000 }

  a.text2:link { color:#00FF00 }
  a.text2:active { color:#FFCC00 }
  a.text2:visited { color:#00CCFF }
  a.text2:hover { color:#FFCC00 }
</style>
<body bgcolor="#FFFFFF">

Notice the blank line I inserted between the two sets of colors. This is so it's easy to see where one set stops and another starts; browsers won't take notice of white space when loading the HTML.

5. Now it's as simple as adding in your text links and applying a class for each one. Within the body of your HTML insert two lines of text for your links. Link each one to anything you please as shown below:

<title>CSS Test</title>
<style>
  a.text1:link { color:#0000FF }
  a.text1:active { color:#FF0000 }
  a.text1:visited { color:#660099 }
  a.text1:hover { color:#FF0000 }

  a.text2:link { color:#00FF00 }
  a.text2:active { color:#FFCC00 }
  a.text2:visited { color:#00CCFF }
  a.text2:hover { color:#FFCC00 }
</style>
<body bgcolor="#FFFFFF">
<a href="b.htm">blue link</a><br>
<a href="g.htm">green link</a>

6. Add the appropriate style to each link, the blue text link goes with 'text1' and green uses 'text2'. Do this by inserting the 'class' attribute within the <a> tags:

<title>CSS Test</title>
<style>
  a.text1:link { color:#0000FF }
  a.text1:active { color:#FF0000 }
  a.text1:visited { color:#660099 }
  a.text1:hover { color:#FF0000 }

  a.text2:link { color:#00FF00 }
  a.text2:active { color:#FFCC00 }
  a.text2:visited { color:#00CCFF }
  a.text2:hover { color:#FFCC00 }
</style>
<body bgcolor="#FFFFFF">
<a href="b.htm" class="text1">blue link</a><br>
<a href="g.htm" class="text2">green link</a>

And it's as simple as that! If you need more than two sets of colors, simply add another style name with it's own set of link-states. Test out your new html page and check out if your coding works correctly.

I've found this technique useful if you need a set of colors for text links but you want to keep the borders on image links at default color values. If you have any questions on this tutorial, please feel free to contact me here.

For more info on CSS and a complete list of attributes, have a look through the MSDN Library.

Online Adult Designs has been providing adult webmasters with quality site and promo designs at reasonable prices for over a year. They can be contacted through ICQ or via their website.

Copyright © 2025 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

opinion

Building Sustainable Revenue Without Opt-Out Cross-Sales

Over the past year, we’ve seen growing pushback from acquirers on merchants using opt-out cross-sales — also known as negative option offers. This has been especially noticeable in the U.S. In fact, one of our acquirers now declines new merchants during onboarding if an opt-out flow is detected. Existing merchants submitting new URLs with opt-out cross-sales are being asked to remove them.

Cathy Beardsley ·
trends

How to Handle Payment Disputes Without Sacrificing Trust

You can run the best-managed and most compliant website out there, but that still doesn’t completely shield you from the risks tied to payment disputes. Buyer’s remorse, an unclear billing description or even a simple misunderstanding can lead a customer to dispute a transaction. Accumulate enough disputes, and both your reputation and revenue could be at risk.

Jonathan Corona ·
trends

WIA Profile: Taylor Moore

With a 70-person team and a growing slate of tools for content creators, the Teasy Agency has developed a reputation for putting talent first. That commitment owes a lot to co-founder Taylor Moore’s own experiences as a cam model.

Jackie Backman ·
profile

WIA Profile: Cathy Turns Creator Platform Experience Into a Model-First Playbook

As both a model and industry executive, Cathy lives in two worlds at once. “Since I do both things, I can act as the liaison between the model community and the rest of the SextPanther team,” she tells XBIZ.

Jackie Backman ·
opinion

From Compliance to Confidence: The Future of Safety in Adult Platforms

In numerous countries and U.S. states, laws now require platforms to prevent minors from accessing age-inappropriate material. But the need for safeguarding doesn’t end with age verification. Today’s online landscape also places adult companies at uniquely high risk for inadvertently facilitating exploitation, abuse or reputational harm, or of being accused of doing so.

Andy Lulham ·
opinion

What Adult Businesses Need to Know About Florida's Age Verification Law

The rise and proliferation of age verification laws has changed the landscape for the online adult industry. A recent and compelling example is the state of Florida, where Attorney General James Uthmeier has filed multiple complaints against major platforms as well as affiliates accused of violating the state’s AV law.

Corey D. Silverstein ·
opinion

Maintaining Brand Trust in the Face of Negative Press

Over the last year, several of our merchants have found themselves caught up in litigation over compliance with state age verification laws. Recently, Segpay itself was pulled into the spotlight, facing scrutiny over Florida’s AV statute, HB 3. These stories inevitably get picked up by both industry and mainstream news outlets.

Cathy Beardsley ·
opinion

How to Switch Payment Processors Without Disrupting Business

For many merchants, the idea of switching payment processors can feel pretty overwhelming. That’s understandable. After all, downtime can stall sales, recurring subscriptions can suddenly fail, or compliance gaps can put accounts at risk. Operating in a high-risk sector like the adult industry can further amplify the stress of transition.

Jonathan Corona ·
profile

WIA Profile: Katie

Katie is the ultimate girl’s girl. As community manager at Chaturbate, she answers DMs, remembers names, and shows up for creators and fellow businesswomen when it counts. She’s quick to credit the people around her, and careful to make space for others in every room she enters.

Women in Adult ·
opinion

How to Stay Legally Protected When Policies Get Outdated

The adult industry has long operated in a complex legal environment subject to rapid change. Now, a confluence of age verification laws, lawsuits, credit card processing and data privacy rules has created an urgent need for all industry participants — from major platforms to independent creators — to review and potentially overhaul their legal and operational policies.

Corey D. Silverstein ·
Show More