View Full Version : How to remove underline from heading links but not other links

07-10-2008, 03:00 PM
I know this a really simple one but it's driving me mad trying to find the answer so please help!

I want all my links to be underlined except the ones that are also headings.

What is the syntax of the selector for all h1,h2,h3 and h4 a:links?


07-10-2008, 03:17 PM
I would use this

h1 a,
h1 a:link,
h1 a:visited,
h1 a:focus,
h1 a:hover,
h1 a:active,
h2 a,
h2 a:link,
h3 a:visited,
h2 a:focus,
h2 a:hover,
h2 a:active,
h3 a,
h3 a:link,
h3 a:visited,
h3 a:focus,
h3 a:hover,
h3 a:active,
h4 a,
h4 a:link,
h4 a:visited,
h4 a:focus,
h4 a:hover,
h4 a:active
text-decoration : none;

It seems a bit long winded and there may be a way to simplify it but you need to put in all the link states (In that order or they may not work properly remember "Luke Vader Former Handle Anakin) because if you don't some other link code later in the style sheet may override particularly focus, hover and active states.

07-10-2008, 03:26 PM
crikey that is long! no wonder i couldn't figure it out - i was looking for a shortcut.

thank you thank you thank you for helping out a confused novice.


07-10-2008, 03:40 PM
Donkey, would it be easier to just use this

* {

not to confuse you hannahkc, but would that be easier to use and then later define a certain element with a decoration somewhere else in the CSS if needed?

07-10-2008, 03:45 PM
Donkey, would it be easier to just use this
Yes JCD you are right, it certainly would be. (Curses! never thought of that one. :~) )

07-10-2008, 03:48 PM
well i didnt want to over-rule your suggestion, i wasnt sure if he was looking for only a specific thing such as a header and link

<h1><a href="#">Link</a></h1>

instead of

<a href="#">Link</a>

Sorry i didnt want to confuse hannahkc at all, haha sorry!