Solved

How to Change Link Font Color Inside a Table

Posted on 2007-11-21
5
7,638 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now