Solved

Specific DIV Hyperlink Color

Posted on 2016-10-10
1
58 Views
Last Modified: 2016-10-12
Hi,
I would like to have a completely unique Hyperlink color for a page as compared to the rest of the website.
So for example, if the active hyperlink color for the website is grey, I would like the active hyperlink color on one particular page to be red.

Can someone explain how this can be done please?


Thanks!
0
Comment
Question by:canu
1 Comment
 
LVL 42

Accepted Solution

by:
zephyr_hex (Megan) earned 500 total points
ID: 41837552
Add a class to the hyperlinks on the "special" page, and then use css to target the class and specify the link color.

HTML
<a href="www.google.com" class="uniqueLink">Google</a>

Open in new window


CSS
.uniqueLink {
  color: red;
}

.uniqueLink:visited {
  color: green;
}

Open in new window


Here is a Fiddle Demo.

If you have a lot of links on the page, it may be more efficient to use a class on a container (whatever contains all of the links).  Here's an example of that approach

HTML
<div class="uniqueLink container">
     <a href="www.google.com">Google</a>
     <a href="www.yahoo.com">Yahoo</a>
</div>

Open in new window


CSS
.uniqueLink > a {
  color: red;
}

.uniqueLink > a:visited {
  color: green;
}

Open in new window


Fiddle Demo.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Changing Color of Page Section 4 21
Scroll 5 news at a time. 4 25
Expand HTML tables without having to click on it 15 37
Under active page on navigation bar 8 11
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question