[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to Change Link Font Color Inside a Table

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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 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 …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

872 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