Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

css href question

Status
Not open for further replies.

riffy

Programmer
Mar 29, 2001
106
US
i have a style sheet in which i've specified the properties for the <a> tag...however is there a way to override it? i have a table with 3 rows and 2 columns..the first and the third row have includes and the first column in the second row has another include...the main content of the page is in the second column of the second row...the <a> tags in that i don't want to have the same properties as specified in the style sheet...but i can't seem to change it...is there a way to do it? the footer and the leftnavigation include use the tag i specified in the css file...how can i add another class that would be used in the main page?
if confusing, let me know and i'll post my code...

arif
:)
 
Try this.

<style>
a{text-decoration:none;}
.caa{text-decoration:underline;}
</style>

<a class=&quot;caa&quot; href=&quot;&quot;></a>

Rick
 
didn't work...it just sees the a tag and doesn't read anything after it...
 
try this.

a.link2:link {text-decoration:none;}
a.link2:hover {text-decoration:underline;}

In your link on your page

<a class=&quot;link2&quot; href=&quot;&quot;></a>

Hope that helps
 
You can create several styles for different <a> tags:

a.first {}
a.first:hover {}
a.first:visited {}

a.second {}
a.second:hover {}
a.second:visited {}

From my experience I can say that this is the best way to do this.

good luck
 
You can overwrite it like this:

<html>
<head>
<style>
a{color: blue;}
#myID{color: purple;}
.myClass{color: green;}
</style></head><body>

<a href=&quot; style=&quot;color: red !IMPORTANT;&quot; id=&quot;myID&quot; class=&quot;myClass&quot;> This link should appear to be red </a></body></html>

The !IMPORTANT tag ensures that the style defined before it
is the overruling style.

Good luck, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
ow yeah, remember the overruling policy of CSS:

1: External Style Sheets. (are overruled by)
2: Style Sheets defined in <HEAD> tag. (are overruled by)
2.1: tag styles (are overruled by)
2.2: class styles (are overruled by)
2.3: id styles
3: Inline Styles.

You can make any of these overrule ALL others by adding
!IMPORTANT in their tag. By the way, the example I gave
in my previous post is a bad one since inline style do
overrule automatically.

<html>
<head>
<style>
a{color: blue !IMPORTANT; }
#myID{color: purple;}
.myClass{color: green;}
</style></head><body>

<a href=&quot; style=&quot;color: red;&quot; id=&quot;myID&quot; class=&quot;myClass&quot;> This link should appear to be blue </a>

</body></html>

Good luck BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
I personally don't like !IMPORTANT and never use it.

If you have to use such a &quot;die-hard&quot; override rule this means that your styles were not designed properly and something is wrong.
If the style layout was designed as it should you can easily avoid the situation where you have to fix some style inconsistency by forcing this rule.



 
I think its an excellent tool. It's just there to speed up designing a site. Just adding a !IMPORTANT tag is a whole
lot faster then redesigning the entire stylesheet. But I do
agree, that when you HAVE to use it, its usually because of
a designflaw.

cheers, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top