Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to Change Link Font Color Inside a Table

Posted on 2007-11-21
5
Medium Priority
?
7,652 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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 …
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).

618 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