Solved

How to Change Link Font Color Inside a Table

Posted on 2007-11-21
5
7,647 Views
Last Modified: 2010-04-21
I have a table defined as follows:

<table width="950" border="0" cellpadding="0" cellspacing="0" style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New">
<tr>
<td width='81' class='class2'><a target=madetail href=tec.php?action=commands>commands</a></td>
<td width='100' class='class2'><a target=madetail href=tec.php?action=list>list</a></td>
</tr>

What I would like to do is to change the font color for the links to white. I tried adding font color=white, but that did't work. Appreciate any guidance.
0
Comment
Question by:dhite99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:Morcalavin
ID: 20328911
If you want to change just those links, you can add a class to your <style> tag.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
 
</script>
<style type="text/css">
	.link
	{
		color: #ffffff;
	}
	.link:hover
	{
		color: #ffffff;
	}
	.link:active
	{
		color: #ffffff;
	}
	.link:visited
	{
		color: #ffffff;
	}
</style>
<title>Untitled Document</title>
</head>
<body style="background-color:purple">
<a class="link" href="#">Test</a>
</body>
</html>

Open in new window

0
 
LVL 6

Expert Comment

by:starfailure
ID: 20329301
if you want to style the links inside the table differently than the rest of the web page, use inheritance in your css:
example:

table a {
  color: #abcdef;
}

table a:hover {
  color: #000000;
}

0
 
LVL 6

Expert Comment

by:starfailure
ID: 20329311
err.. don't know why i said "inheritance".  i mean Hierarchy
0
 
LVL 1

Accepted Solution

by:
edenmachine earned 100 total points
ID: 20335748
Worse case scenario you add a span tag inside of the <a> tag like so:

<td width='81' class='class2'><a target=madetail href=tec.php?action=commands><span style="color:white;">commands</span></a></td>

HOWEVER - this is the best and "more correct" way to do it:
inside your style you should put a NEW entry:

.class2 a {color:white;}

You might also need to and these depending on how your stylesheet is setup:
.class2 a:link {color:white;}
.class2 a:active {color:white;}
.class2 a:visited {color:white;}
.class2 a:hover {color:yellow;} /*or whatever the hover color you'd like */


Basically this tells your page that whenever there is an <a> tag inside another tag that has the "class2" style attribute that the color of the font for that <a> tag needs to be white.  This will keep all your other <a> tag font colors normal and will only affect the ones inside the class2 style.




.class2
0
 

Author Closing Comment

by:dhite99
ID: 31410399
Worked like a champ - THANKS!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

695 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