Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Multiple linking with different colors in one document

Featured Replies

I am having a problem linking two sets of type on a page. I have 2 CSS pages attached to the htm page. One set of links is on a dark background, the other links are on a light background. The links on the light background are turning white but I want them to be dark blue. I thought that if I have two separate a:link and a:visited in the separate CSS pages, that this wouldn’t happen. Anyone have any answers before I pull my hair out!?

 

Thanks a mil.

I am having a problem linking two sets of type on a page. I have 2 CSS pages attached to the htm page. One set of links is on a dark background, the other links are on a light background. The links on the light background are turning white but I want them to be dark blue. I thought that if I have two separate a:link and a:visited in the separate CSS pages, that this wouldn’t happen. Anyone have any answers before I pull my hair out!?

 

Thanks a mil.

 

If both CSS files are being called, it'll use the last style specified for the selector. Are the two CSS files simply alternative stylesheets for the same html page?

you could always set the link to have a class if you want it to be different

 

 

like this:

 

HTML:

<a href="#" class="one">one link</a>
<a href="#" class=" two">two link</a>

 

 

CSS:

 

a.one { 
color:#CC0099}
a.one:hover { 
color:#3300CC}

a.two {
color:#CCFF00;
text-decoration: none;}

a.two:hover { 
color:#FF0000}

  • Author
If both CSS files are being called, it'll use the last style specified for the selector. Are the two CSS files simply alternative stylesheets for the same html page?

 

 

Yes that’s right..it’s for the same html page. Thanks for your help.

  • Author
you could always set the link to have a class if you want it to be different

like this:

 

HTML:

<a href="#" class="one">one link</a>
<a href="#" class=" two">two link</a>

CSS:

 

a.one { 
color:#CC0099}
a.one:hover { 
color:#3300CC}

a.two {
color:#CCFF00;
text-decoration: none;}

a.two:hover { 
color:#FF0000}

 

I will try this and see if it works. Thanks. Will let you know!

  • Author
I will try this and see if it works. Thanks. Will let you know!

 

It’s probably easier if you see the document and its CSS file so go here:

 

http://www.enlightenedoils.net/linkstest.htm

 

Here is the CSS page:

 

http://www.enlightenedoils.net/links.css

 

As you can see, the links in the center of the page are taking on the colors of the bottom bar. I don’ t want that. I want to make them different colors for the links. Where do I insert the code in my documents? Thanks so much!

 

4silverstrea

Hi There,

 

What Dizi has posted is exactly what you need to do.

 

You have two different types of links, so you need to define them to be different.

 

If you want the ones in the center of the page to be a different colour then you need to add a class to them:

 

As per Dizi's HTML:

<a href="#" class="one">one link</a>
<a href="#" class="two">two link</a>

 

Look at the a tag, you can see there is an extra attribute compared to what you have, this attribute is called "class" and it allows you to create a separate style for that link.

 

So links with class="one" will all look the same, links with class="two" will all look the same, and links without any class at all will all look the same.

 

Now to change what each class looks like you need to define the classes in your css

 

a.one {
color:#CC0099}
a.one:hover {
color:#3300CC}

a.two {
color:#CCFF00;
text-decoration: none;}

a.two:hover {
color:#FF0000}

 

Look carefully and you will see that both the standard and the hover colour has been set for both classes one and two.

 

You do this by first calling the tag that has the class, in this case "a", and then putting the class name but starting with a "."

 

so a.one and a.two

 

You can omit the a if you want.

 

In Dizi's example a.one has been given the colour #CC0099 (bright pink) and a.two has been given the colour #CCFF00 (bright green).

 

In your HTML file you need to choose which links you want to display differently (so the center links) and add a class attribute you all of them, for example class="centerlinks" then in your css you need to define what they look like so a.centerlinks { }.

 

This will do what you want.

 

In your HTML file you need to clear up all of your styles, you have several styles defined in the HTML in <style> tags at the top, these need to be placed in your css file. Also you have defined two different css files, you only need the one as defining different styles in different documents will not help you, you need to use classes as above.

 

- Eris

  • Author
Hi There,

 

What Dizi has posted is exactly what you need to do.

 

You have two different types of links, so you need to define them to be different.

 

If you want the ones in the center of the page to be a different colour then you need to add a class to them:

 

As per Dizi's HTML:

<a href="#" class="one">one link</a>
<a href="#" class="two">two link</a>

 

Look at the a tag, you can see there is an extra attribute compared to what you have, this attribute is called "class" and it allows you to create a separate style for that link.

 

So links with class="one" will all look the same, links with class="two" will all look the same, and links without any class at all will all look the same.

 

Now to change what each class looks like you need to define the classes in your css

 

a.one {
color:#CC0099}
a.one:hover {
color:#3300CC}

a.two {
color:#CCFF00;
text-decoration: none;}

a.two:hover {
color:#FF0000}

 

Look carefully and you will see that both the standard and the hover colour has been set for both classes one and two.

 

You do this by first calling the tag that has the class, in this case "a", and then putting the class name but starting with a "."

 

so a.one and a.two

 

You can omit the a if you want.

 

In Dizi's example a.one has been given the colour #CC0099 (bright pink) and a.two has been given the colour #CCFF00 (bright green).

 

In your HTML file you need to choose which links you want to display differently (so the center links) and add a class attribute you all of them, for example class="centerlinks" then in your css you need to define what they look like so a.centerlinks { }.

 

This will do what you want.

 

In your HTML file you need to clear up all of your styles, you have several styles defined in the HTML in <style> tags at the top, these need to be placed in your css file. Also you have defined two different css files, you only need the one as defining different styles in different documents will not help you, you need to use classes as above.

 

- Eris

 

So where do put this on the HTML page, above the two href links under style?

</style>

<link href="links.css" rel="stylesheet" type="text/css">

<link href="btmmenulinks.css" rel="stylesheet" type="text/css">

Get rid of your btmmenulinks.css and the class="btmmenulinks.css" in your <th>.

 

You do not need to define an entire new style sheet for a class.

 

You need to put the class name code into your links...inside the individual <a> tags as it is shown in the post.

 

The styling goes into the one stylesheet that you keep i.e. inside links.css

  • Author
Get rid of your btmmenulinks.css and the class="btmmenulinks.css" in your <th>.

 

You do not need to define an entire new style sheet for a class.

 

You need to put the class name code into your links...inside the individual <a> tags as it is shown in the post.

 

The styling goes into the one stylesheet that you keep i.e. inside links.css

 

 

Thanks Eris. This makes sense.By the way, I love your signature quotes!

 

4silverstrea

Hehe! I'm glad it's starting to make sense, hope you manage to get it working :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.