473,796 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remove link styles on images

5 New Member
Hi,

I've only just started playing about with CSS so there might be a really obvious answer to this.

In my style sheet i have the following to style the hyperlinks on the page:

Expand|Select|Wrap|Line Numbers
  1. a:link {color: #0000ff;}
  2. a:visited:hover {color: #FFD; background-color: #0000ff;}
  3. a:link:hover {color: #FFD; background-color: #0000ff;}
Only problem is, any images on the page that are also link get the hover style applied to them, so they get an ugly blue border around them when you hover over them. How can i stop this happening?

Cheers
Luke
Sep 10 '07
16 16827
drhowarddrfine
7,435 Recognized Expert Expert
but if it works by giving each link an "id" that the images don't have, therefor only changing the colors of the "text" links then where is the problem?
If it works this time then there is no problem, but if he tries to use that element for anything else, such as those listed in the spec, there will be a problem. It messes up the document tree for the browser. Kind of like you can have a math problem that has an error in it but still gives you the right answer, until you try inserting different values into the equation.
Sep 11 '07 #11
Death Slaught
1,137 Top Contributor
If it works this time then there is no problem, but if he tries to use that element for anything else, such as those listed in the spec, there will be a problem. It messes up the document tree for the browser. Kind of like you can have a math problem that has an error in it but still gives you the right answer, until you try inserting different values into the equation.
ok I'm not really sure what you meen, but I think your saying that having an "id" for the links only are fine, but by adding the "id" attribute with a different value that it will create a problem. I don't think it's what you ment but I tried it anyways. Here are the results:


I took 5 links wich all led to a different web site i gave them each a different "id" and different values in the CSS, it worked perfectly.

So then I added 5 image links all with different "id's" and different values once again it worked perfectly.

After that I had my doubts that I understood what you were saying so I took all 10 links the 5 "text" links and the 5 "image" links and made 5 of each one.
So that gave me this:

[HTML]<a href="http://hotmail.com" id="link">Go to Hotmail</a>
<a href="http://hotmail.com" id="link">Go to Hotmail</a>
<a href="http://hotmail.com" id="link">Go to Hotmail</a>
<a href="http://hotmail.com" id="link">Go to Hotmail</a>
<a href="http://hotmail.com" id="link">Go to Hotmail</a>

<a href="http://thescripts.com" id="link2">Go to Thescripts</a>
<a href="http://thescripts.com" id="link2">Go to Thescripts</a>
<a href="http://thescripts.com" id="link2">Go to Thescripts</a>
<a href="http://thescripts.com" id="link2">Go to Thescripts</a>
<a href="http://thescripts.com" id="link2">Go to Thescripts</a>

<a href="http://yahoo.com" id="link3">Go to Yahoo</a>
<a href="http://yahoo.com" id="link3">Go to Yahoo</a>
<a href="http://yahoo.com" id="link3">Go to Yahoo</a>
<a href="http://yahoo.com" id="link3">Go to Yahoo</a>
<a href="http://yahoo.com" id="link3">Go to Yahoo</a>

<a href="http://google.com" id="link4">Go to Google</a>
<a href="http://google.com" id="link4">Go to Google</a>
<a href="http://google.com" id="link4">Go to Google</a>
<a href="http://google.com" id="link4">Go to Google</a>
<a href="http://google.com" id="link4">Go to Google</a>

<a href="http://ask.com" id="link5">Go to Ask</a>
<a href="http://ask.com" id="link5">Go to Ask</a>
<a href="http://ask.com" id="link5">Go to Ask</a>
<a href="http://ask.com" id="link5">Go to Ask</a>
<a href="http://ask.com" id="link5">Go to Ask</a>

<a href="http://myspace.com" id="link6">
<img border="0" src="http://a148.ac-images.myspacec dn.com/images01/33/s_38274e869726c 70d26d6f87c2785 e7d3" />
Meet David on Myspace
</a>
<a href="http://myspace.com" id="link6">
<img border="0" src="http://a148.ac-images.myspacec dn.com/images01/33/s_38274e869726c 70d26d6f87c2785 e7d3" />
Meet David on Myspace
</a>
<a href="http://myspace.com" id="link6">
<img border="0" src="http://a148.ac-images.myspacec dn.com/images01/33/s_38274e869726c 70d26d6f87c2785 e7d3" />
Meet David on Myspace
</a>
<a href="http://myspace.com" id="link6">
<img border="0" src="http://a148.ac-images.myspacec dn.com/images01/33/s_38274e869726c 70d26d6f87c2785 e7d3" />
Meet David on Myspace
</a>
<a href="http://myspace.com" id="link6">
<img border="0" src="http://a148.ac-images.myspacec dn.com/images01/33/s_38274e869726c 70d26d6f87c2785 e7d3" />
Meet David on Myspace
</a>

<a href="http://images.google.c om/images?hl=en&q= flower&gbv=2" id="link7">
<img border="0" src="http://tbn0.google.com/images?q=tbn:vK gBfyLa3EBATM:ht tp://pinker.wjh.harv ard.edu/photos/new_zealand_II/images/lotus%2520flowe r.jpg" />
Find flowers like this and many more on Google
</a>
<a href="http://images.google.c om/images?hl=en&q= flower&gbv=2" id="link7">
<img border="0" src="http://tbn0.google.com/images?q=tbn:vK gBfyLa3EBATM:ht tp://pinker.wjh.harv ard.edu/photos/new_zealand_II/images/lotus%2520flowe r.jpg" />
Find flowers like this and many more on Google
</a>
<a href="http://images.google.c om/images?hl=en&q= flower&gbv=2" id="link7">
<img border="0" src="http://tbn0.google.com/images?q=tbn:vK gBfyLa3EBATM:ht tp://pinker.wjh.harv ard.edu/photos/new_zealand_II/images/lotus%2520flowe r.jpg" />
Find flowers like this and many more on Google
</a>
<a href="http://images.google.c om/images?hl=en&q= flower&gbv=2" id="link7">
<img border="0" src="http://tbn0.google.com/images?q=tbn:vK gBfyLa3EBATM:ht tp://pinker.wjh.harv ard.edu/photos/new_zealand_II/images/lotus%2520flowe r.jpg" />
Find flowers like this and many more on Google
</a>
<a href="http://images.google.c om/images?hl=en&q= flower&gbv=2" id="link7">
<img border="0" src="http://tbn0.google.com/images?q=tbn:vK gBfyLa3EBATM:ht tp://pinker.wjh.harv ard.edu/photos/new_zealand_II/images/lotus%2520flowe r.jpg" />
Find flowers like this and many more on Google
</a>

<a href="http://autos.yahoo.com/;_ylc=X3oDMTE5M GRqZDdoBF9TAzI3 MTYxNDkEc2VjA2Z wLXRyb3VnaARzbG sDc3Bpcml0LWZpe GVk" id="link8">
<img border="0" src="http://ads.yimg.com/us.yimg.com/a/fo/ford/fusion-180x100.jpg" />
Find cars on Yahoo
</a>
<a href="http://autos.yahoo.com/;_ylc=X3oDMTE5M GRqZDdoBF9TAzI3 MTYxNDkEc2VjA2Z wLXRyb3VnaARzbG sDc3Bpcml0LWZpe GVk" id="link8">
<img border="0" src="http://ads.yimg.com/us.yimg.com/a/fo/ford/fusion-180x100.jpg" />
Find cars on Yahoo
</a>
<a href="http://autos.yahoo.com/;_ylc=X3oDMTE5M GRqZDdoBF9TAzI3 MTYxNDkEc2VjA2Z wLXRyb3VnaARzbG sDc3Bpcml0LWZpe GVk" id="link8">
<img border="0" src="http://ads.yimg.com/us.yimg.com/a/fo/ford/fusion-180x100.jpg" />
Find cars on Yahoo
</a>
<a href="http://autos.yahoo.com/;_ylc=X3oDMTE5M GRqZDdoBF9TAzI3 MTYxNDkEc2VjA2Z wLXRyb3VnaARzbG sDc3Bpcml0LWZpe GVk" id="link8">
<img border="0" src="http://ads.yimg.com/us.yimg.com/a/fo/ford/fusion-180x100.jpg" />
Find cars on Yahoo
</a>
<a href="http://autos.yahoo.com/;_ylc=X3oDMTE5M GRqZDdoBF9TAzI3 MTYxNDkEc2VjA2Z wLXRyb3VnaARzbG sDc3Bpcml0LWZpe GVk" id="link8">
<img border="0" src="http://ads.yimg.com/us.yimg.com/a/fo/ford/fusion-180x100.jpg" />
Find cars on Yahoo
</a>

<a href="http://news.ask.com/news?qsrc=&o=0& l=dir" id="link9">
<img border="0" src="http://ak.imgfarm.com/images/ap/gallery/Bush.sff_DCSA10 7_2007091116395 2.jpg" />
Find the latest on George Bush with Ask.com
</a>
<a href="http://news.ask.com/news?qsrc=&o=0& l=dir" id="link9">
<img border="0" src="http://ak.imgfarm.com/images/ap/gallery/Bush.sff_DCSA10 7_2007091116395 2.jpg" />
Find the latest on George Bush with Ask.com
</a>
<a href="http://news.ask.com/news?qsrc=&o=0& l=dir" id="link9">
<img border="0" src="http://ak.imgfarm.com/images/ap/gallery/Bush.sff_DCSA10 7_2007091116395 2.jpg" />
Find the latest on George Bush with Ask.com
</a>
<a href="http://news.ask.com/news?qsrc=&o=0& l=dir" id="link9">
<img border="0" src="http://ak.imgfarm.com/images/ap/gallery/Bush.sff_DCSA10 7_2007091116395 2.jpg" />
Find the latest on George Bush with Ask.com
</a>
<a href="http://news.ask.com/news?qsrc=&o=0& l=dir" id="link9">
<img border="0" src="http://ak.imgfarm.com/images/ap/gallery/Bush.sff_DCSA10 7_2007091116395 2.jpg" />
Find the latest on George Bush with Ask.com
</a>

<a href="http://www.thescripts. com/forum/member.php?u=37 720" id="link10">
<img border="0" src="http://www.thescripts. com/forum/customavatars/avatar37720_2.g if" />
Find out about drhowarddrfine at Thescripts.com
</a>
<a href="http://www.thescripts. com/forum/member.php?u=37 720" id="link10">
<img border="0" src="http://www.thescripts. com/forum/customavatars/avatar37720_2.g if" />
Find out about drhowarddrfine at Thescripts.com
</a>
<a href="http://www.thescripts. com/forum/member.php?u=37 720" id="link10">
<img border="0" src="http://www.thescripts. com/forum/customavatars/avatar37720_2.g if" />
Find out about drhowarddrfine at Thescripts.com
</a>
<a href="http://www.thescripts. com/forum/member.php?u=37 720" id="link10">
<img border="0" src="http://www.thescripts. com/forum/customavatars/avatar37720_2.g if" />
Find out about drhowarddrfine at Thescripts.com
</a>
<a href="http://www.thescripts. com/forum/member.php?u=37 720" id="link10">
<img border="0" src="http://www.thescripts. com/forum/customavatars/avatar37720_2.g if" />
Find out about drhowarddrfine at Thescripts.com
</a>[/HTML]

and heres the CSS:

Expand|Select|Wrap|Line Numbers
  1. a#link
  2. {
  3. color: #33000;
  4. hover: #330033;
  5. background-color: #330066;
  6. }
  7.  
  8. a#link2
  9. {
  10. color: #660000;
  11. hover: #660033;
  12. background-color: #660066;
  13. }
  14.  
  15. a#link3
  16. {
  17. color: #990000;
  18. hover: #990033;
  19. background: #990066;
  20. }
  21.  
  22. a#link4
  23. {
  24. color: #cc0000;
  25. hover: #cc0033;
  26. background-color: #cc0066;
  27. }
  28.  
  29. a#link5
  30. {
  31. color: #ff0000;
  32. hover: #ff0033;
  33. background-color: #ff0066;
  34. }
  35.  
  36. a#link6
  37. {
  38. color: #009900;
  39. hover: #009933;
  40. background-color: #009966;
  41. }
  42.  
  43. a#link7
  44. {
  45. color: #339900;
  46. hover: #339933;
  47. background-color: #339966;
  48. }
  49.  
  50. a#link8
  51. {
  52. color: #669900;
  53. hover: #669933;
  54. background-color: #669966;
  55. }
  56.  
  57. a#link9
  58. {
  59. color: #999900;
  60. hover: #999933;
  61. background-color: #999966;
  62. }
  63.  
  64. a#link10
  65. {
  66. color: #cccc00;
  67. hover: #cccc33;
  68. background-color: #000000;
  69. }
I realize that it's total chaos, but once again it works perfectly. So please inlightin me on what you ment.

Thanks, Death
Sep 11 '07 #12
drhowarddrfine
7,435 Recognized Expert Expert
You have to separate what you can get to work from what other problems you may cause or have later on. I know 'id' will work that way but you are forgetting the side affects should you want to do something with, say, javascript.

For example, if you tried to use getElementById( ), but had multiple id names, the function would not know what to return because it can only return one element with one unique name.

So your example becomes "yes, it works, but...."
Sep 12 '07 #13
drhowarddrfine
7,435 Recognized Expert Expert
Speak of the devil. .
Sep 12 '07 #14
Death Slaught
1,137 Top Contributor
You have to separate what you can get to work from what other problems you may cause or have later on. I know 'id' will work that way but you are forgetting the side affects should you want to do something with, say, javascript.

For example, if you tried to use getElementById( ), but had multiple id names, the function would not know what to return because it can only return one element with one unique name.

So your example becomes "yes, it works, but...."
I think i understand what your saying now, but just because i'm having so much fun with the (i know you are 2) ima try and get it to work in javascript, in other words get it to call about 3 different "id"s THIS IS SO GONA BLOW UP IN MY FACE, AND I CAN'T WAIT!!!!!!!

- Death
Sep 13 '07 #15
Death Slaught
1,137 Top Contributor
Speak of the devil. .
lol you posted it twice and he ignored you.
Sep 13 '07 #16
brettl
41 New Member
It's not valid HTML.

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).
Sep 19 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

22
5151
by: Jonathan Snook | last post by:
I've been contemplating what the recommended usage of a "top of page" link should be? Should there only ever be one at the bottom of the page? Should they be sprinkled at various points on the page? Or should they be used at all? Lately, I've been leaning towards the last option because my thought is that most browsers have a method to make it back to the top of the page (home button, scroll bar, whatever). It seems I never use the...
7
23026
by: lawrence | last post by:
In my style sheet I've set the links like this: a:link{ text-decoration:none; } I did that for the pseudo classes and I also did that for the image tag. Yet there are still link lines around the images. Why? It's on this page:
7
5863
by: Greg Raven | last post by:
I styled my links just the way I want them using CSS, but now my linked images have picked up these same styles. I've tried turning the styles off for the images with: a img { text-decoration: none; outline: none; margin: 0px; padding: 0px;
4
4839
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the value of the "id" field of that record as a URL parameter. Can someone tell me how to do this.
19
10239
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However when I deploy to a remote test server running real IIS, the real root of my application becomes: http://localhost/ What I want to do is have it so that on my local machine the asp.net dev
2
7030
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
2
1757
by: John A. | last post by:
Hello. I'm trying to have an image (a GIF with transparency) overlayed on certain of several inline images that link to different pages. What I have so far looks right (or right enough) in both SeaMonkey (mozilla) and IE6, but in IE6 the link isn't clickable. It shows the destination URL in the status bar but the cursor remains an arrow and nothing happens when I click. In SeaMonkey it works just fine.
4
7715
by: R.A.M. | last post by:
Hi, I have created ASP.NET application with forms authentication (Login.aspx). The problem is that although Login.aspx contains CSS styles and JPEG/GIF images, usually the styles are not applied and images are not displayed. I mean, if I run application from Visual Studio at about 80% of times the styles and images are not applied - black and white page without images (only rectangular ares). I am not sure but I think I saw this effect on...
27
3881
by: GloStix | last post by:
WARNING VIDEO TAKES A WHILE TO LOAD http://screencast.com/t/BWQ6DNtsM I really don't know how to fix this other than putting another div. But I dont' exactly want to do that for every page. random div's everywhere Is there any other way? Also I'm trying to get a scaled thumbnail of the orginal picture WHILE maintaining the size of the css box.. Is that possible? Or do I have to scale it in Photoshop and make a separate image =\
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.