Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2005, 11:05 PM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sfs00784 Send a message via MSN to sfs00784
Default How to remove the underline of the Image

a{
border-bottom:dotted 1px #990000;
color:#990000;
text-decoration:none
}
a:active,a:focus,a:hover{
border-bottom:solid #333;
color:#333
}

/* The following code seems no use to remove the underline *

a:link img,a:visited img{
border-bottom:0px;
border-style:none
}
a img {color: black} /* The only way to hide the border in NS 4.x */

Hope somebody can help me, thank you.

|:|KUNG|:|
 
Old June 22nd, 2005, 01:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Try this:

img
{
  border: 0;
}

the border is on the image; not the a....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 22nd, 2005, 07:42 AM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sfs00784 Send a message via MSN to sfs00784
Default

Sorry to tell you that is doesn't work.

If I remove the following code,
border-bottom:dotted 1px #990000;
text-decoration:none

the following work correctly:
a:link img,a:visited img{
border-bottom:0px;
border-style:none
}
a img {color: black} /* The only way to hide the border in NS 4.x */

So I think that it is the problem of
border-bottom:dotted 1px #990000;

However, I don't know how to deal with this problem.
Hope somebody can help me.
Thanks in advance.

|:|KUNG|:|
 
Old June 22nd, 2005, 12:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you missed my point. There is no need to use this:

a:link img

That would try to change images within an <a> tag. However, the img selector I showed you earlier removes the border from any image within an <a> tag, so there is no need to do that again.

Look at the following example:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <title>Untitled Document</title>
  <style type="text/css">
  img 
  {
    border: none;
  }
  </style>
</head>
<body>
  <a href="#"><img src="Images/SomeImage.gif"></a>
</body>
</html>
You'll see no border around the image.
I believe in Netscape 4 there is no other way to diable the border than to use the border="0" attribute.

Your code, border: black; is not removing the border; it's setting it to black so you no longer see it.... ;)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 24th, 2005, 10:06 PM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sfs00784 Send a message via MSN to sfs00784
Default

To have a look, thank you.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-HK" lang="zh-HK">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<link rel="stylesheet" type="text/css" href="StyleSheets/xkboard.css" />
<style type="text/css">
<!--
a{
    border-bottom: dotted 1px #990000;
    color: #990000;
    text-decoration: none
}

a:active,a:focus,a:hover{
    border-bottom: solid #333;
    color: #333
}

body{
    color: #404040;
    font-family: Arial,Helvetica,sans-serif;
    margin: 0
}

body, html,p{
    padding: 0
}

img{
    border: 0px
}
-->
</style>
</head>

<body>

<div id="ads">
  <a href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a> <a href="http://jigsaw.w3.org/css-validator/validator?uri=http://www.knetbbs.com/Skin/klite/StyleSheets/xkboard.css" shape="rect"><img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /></a>
</div>

</body>
</html>
|:|KUNG|:|
 
Old June 24th, 2005, 10:29 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

It looks like you have a specificity issue.

The bottom border under the image is because of the rule for the links, not the image. The following...

img {
   border: none;
}

...works to remove the default border from the image, but you still have a bottom border because of the link styles.

So, you need to add more styles.

For instance:

div#ads a {
    border: none;
}

That's more specific than a:active, etc, because there is an id selector present, it will win over those rules and remove the border. Of course you only want to target the images with links, so you might invent some sort of wrapping element just to go around images with links. What I normally do is this:

<p class='caption'>
    <a href='#'><img src='' alt='' /></a>
</p>

That leaves me an option to style images with links, and images with captions. Just my personal preference though. Unfortunately there is no way to select an element's parent in CSS, so there really isn't a better way of doing it.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old June 25th, 2005, 11:10 PM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sfs00784 Send a message via MSN to sfs00784
Default

The problem is solved, thank you very much for your help.

Simplified Chinese:
http://www.knetbbs.com/

A Valid XHTML 1.0 Strict & CSS 2.0 ASP.NET 1.1 Forum.
English Version will release in July or August.

|:|KUNG|:|





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need underline for did you mean ssvas BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 November 27th, 2008 03:05 AM
set image on <asp:Image> stored in DataBase myself.panku ASP.NET 2.0 Professional 1 August 11th, 2008 10:41 AM
Linked Images in Firefox Showing Underline kwilliams CSS Cascading Style Sheets 1 March 27th, 2008 03:01 PM
How can display underline of text in Button when m mycwcgr ASP.NET 2.0 Basics 6 September 6th, 2007 01:32 PM
convert text to bold/italic/underline arunkhushi General .NET 0 August 21st, 2007 04:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.