Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

changing the colors of links

amd.64

Coder
I am new to the forums, and although I have done web design in HTML, Java Script and CGI it has been awhile, about 20 years in fact. I have don very little with CSS. Please bear with me as I will likely have several questions. I do have extensive experience with Visual Basic, I have had Java and C# classes but that is where it ended. So I at least have the foundations for scripting and programming

Is it possible to change the colors of links, visited and hover multiple times on a single page?

IE if I have two groups of links can I have one set of links behave one way and the second group behave another?
 
Last edited:
I am new to the forums, and although I have done web design in HTML, Java Script and CGI it has been awhile, about 20 years in fact. I have don very little with CSS. Please bear with me as I will likely have several questions. I do have extensive experience with Visual Basic, I have had Java and C# classes but that is where it ended. So I at least have the foundations for scripting and programming

Is it possible to change the colors of links, visited and hover multiple times on a single page?

IE if I have two groups of links can I have one set of links behave one way and the second group behave another?
Is this for something you are creating? If so, yes, there's a few different ways you can code your page to do so
 
So to provide you with the best solution... can you describe what you are looking for? I know you asked "Is it possible to change the colors of links, visited and hover multiple times on a single page?", but can you clarify what you mean by "multiple times"? Do you mean that every time a user hovers over the link, it changes the color to a new one?
 
I am having problems getting this to work. Below is what I have in the styles.css file.

Is there an issue here or do I need to look elsewhere?

Code:
a.group1:link {color: #033f69;}
    a.group1:visited {color: black;}


    a.group2:link {color: purple;}
    a.group2:visited {color: gold;}
 
Here is a working example of a way:

CSS:
.group-a a:any-link {
    color: green;
}
.group-a a:hover {
    color: red;
}

.group-b a:any-link {
    color: #ffa500;
}

.group-b a:hover {
    color: rgb(20,108,205);
}

HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <div class="group-a">
        <a href="#">Link 1</a><br />
        <a href="#">Link 2</a><br />
    </div>
    <hr>
    <div class="group-b">
        <a href="#">Link 3</a><br />
        <a href="#">Link 4</a><br />
    </div>
</body>
</html>
 
Back
Top Bottom