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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

{text-decoration:none} question

Status
Not open for further replies.

SteveHigh

Technical User
Jan 17, 2007
158
0
0
GB
Hello

I have the following in CSS:

BODY { text-decoration:none; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}

However, the link I have on my page is shown as blue underlined, suggesting that I have misplaced the BODY { text-decoration:none;}.

How can I use it, then, please so that it shows in the same colour as the rest of the black text without an underline?

I do not want to use a separate:

p { text-decoration:none }

because this only causes the text to produce this kind of effect:

The quick brown fox lazy dog.

jumped over the

Many thanks.

Steve
 
Since text-decoration:none only works on links you need to use it on links.

Code:
a:link{
text-decoration:none;
}



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Although vacunita is right in what you need to do, a few things need to be explained:

1. text-decoration can be applied to any object, but links have a text-decoration: underline applied by most browsers by default.

2. Your CSS is correct and works as it should. Why is it not working in the way you want, can be explained by your own quote.
Steve said:
However, the link I have on my page is shown as blue underlined, suggesting that I have misplaced the BODY { text-decoration:none;}.
You have misplaced the text-decoration, but body is OK in this declaration. You were styling the body of the document and you wanted link styled. While some attributes are inherited by all the children of the element (such as font declaration), others have to be defined specifically for each element (such as borders, paddings, margins and text-decoration). That is why all the content in your body element had no text decoration but other elements within the body had their default text-decoration. That would be none for all the elements except for link. And that is why you need to address the text-decoration specification on the link itself.
Code:
a {
  text-decoration: none;
}
By not specifying that you want to apply it to :link (default, unclicked, unhovered state), it will apply to all states.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top