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, Inheritance tags

Status
Not open for further replies.

ziploc1010

Programmer
Apr 14, 2001
13
US

I'd like to add some css to my anchor tag. To do this, I would:
<style type=&quot;text/css&quot;>
A {
font: 13pt/15pt &quot;Arial&quot;;
}
</style>

But what if I wanted a special anchor tag? I don't want to change my style for every anchor tag. So is it possible to create a new class that inherents all of the properties of the regular anchor tag.

I want to do something like this:

<style type=&quot;text/css&quot;>
As {
*inherent all of A's properties*
font: 13pt/15pt &quot;Arial&quot;;
}
</style>


Then instead of doing <A ....
I can do <As ...


Thanks in advance,
Matthew
 
This is possible by using the CLASS attribute inside the A tag such as:

[tt]
<A HREF=&quot;about:blank&quot; CLASS=&quot;specialA&quot;>Special Link</A>



<STYLE>
A {
font-family: arial;
font-weight: normal;
font-size: 12pt;
color: blue;
}

A.specialA {
font-weight: bold;
font-size: 13pt;
text-decoration: underline;
} /* This class inherits all A's settings and overrides the ones specified and adds the new ones to the css class */
</STYLE>

[/tt] I hope this helped! ;-)
- Casey Winans
 
Wow that's really cool.

Is there any way to go down more than one level with classes?

Such as:

A {
font-family: arial;
font-weight: normal;
font-size: 12pt;
color: blue;
}

A.specialA {
font-weight: bold;
font-size: 13pt;
text-decoration: underline;
}

A.specialA.noBold {
font-weight: normal;
}

<A HREF=&quot;about:blank&quot; CLASS=&quot;noBold&quot;>Special Link</A>

Is that possible?

 
Not as of yet... to the best of my knowledge yet.

That would be nice!

I'd like to be able to do something like this...

A.noBold {
inherit: specialA;
font-weight: normal;
}

but it's not supported and I dont' know if it will ever be.

Later.

I hope this helped! ;-)
- Casey Winans
 
I think you can do this


A:specialA {
font-weight: bold;
font-size: 13pt;
text-decoration: underline;
}

A:specialA .noBold {
font-weight: normal;
}

Although I'm not completely sure if it works.

Earme
 
No.

The only values able to go after &quot;A:&quot; are: link, active, visited, and hover.

Those are the 4 states a link can be in.

Later. I hope this helped! ;-)
- Casey Winans
 
Something I have seen is specifying where the anchor is, instead of what class -

div.menu a {
font: 12pt Verdana;
}

Just something I have seen. you can still use classes with the a, but also specify by parent. Dean Owen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top