Kevin
Kevin

Reputation: 1624

Remove underline in hyperlink

I need to get rid of an underline in a hyperlink.

<div id='something'>
   <h2>
      <a href='http://somerandomurl'>Photo</a>
   </h2>
</div>

I'm using this CSS, but it won't work.

#something h2 a{text-decoration:none}

Upvotes: 0

Views: 8667

Answers (4)

lbrendanl
lbrendanl

Reputation: 2674

Here is the css you want:

#something a:link {text-decoration:none;}
#something a:visited {text-decoration:none;}
#something a:hover {text-decoration:underline;}
#something a:active {text-decoration:underline;}

The specific CSS you want to target depends on what exactly you are looking for. For example, if you want all links in 'something' to not be underlined, do what I wrote above. But if you wanted all links to not be underlined, you would not put the #something, etc. Read about context selectors if your not sure what I mean. Here is good link.

http://www.daaq.net/old/css/index.php?page=css+context+selectors&parent=css+syntax

Hope that helps

Upvotes: 5

Timbadu
Timbadu

Reputation: 1551

a:link, a:visited { text-decoration: none; }

Upvotes: 1

Nick Rolando
Nick Rolando

Reputation: 26177

The style you have should work, except the id in your selector is wrong..it should be

#something h2 a{text-decoration:none}

http://jsfiddle.net/V4e8m/2/

Upvotes: 1

raddrick
raddrick

Reputation: 4463

what is #ugc?

you need...

#something h2 a { text-decoration: none; }

you can also define

a:hover, a:link, a:visited

...if needed for different states

Upvotes: 1

Related Questions