473,785 Members | 2,887 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 #1
16 16825
Death Slaught
1,137 Top Contributor
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
I would try giving your "<a>" tags for your non-image links an "id" like this:


Heres the HTML:

[HTML]<html>
<head>
<link rel="stylesheet " type="text/css"
href="location of the CSS document" />
</head>
<body>
<a href="where u want it to go" id="link">what you want it to say</a>
<a href="where u want it to go" id="link">what you want it to say</a>
<a href="where u want it to go">
<img border="0" src="location of image" />
</a>
</body>
</html>[/HTML]

and heres the CSS:

Expand|Select|Wrap|Line Numbers
  1. a#link
  2. {
  3. color: red;
  4. hover: black;
  5. background-color: black;
  6. }
Hope it helps, Death
Sep 10 '07 #2
beakersoft
5 New Member
Hi,

I think that should work, but it means i'll have to make sure i add that class to all my links. Is there nothing I can do that's global that just says if a image within a href tag, dont apply the styles

Cheers
Luke
Sep 11 '07 #3
Death Slaught
1,137 Top Contributor
Hi,

I think that should work, but it means i'll have to make sure i add that class to all my links. Is there nothing I can do that's global that just says if a image within a href tag, dont apply the styles

Cheers
Luke
hmm i'm not sure.....I'll look into it and see if there's another way but i don't think there is. Although adding id="" isnt going to kill you, your gona have to type alot anyways so a little bit more shouldnt hurt. I'll post back if i find anything.

- Death
Sep 11 '07 #4
drhowarddrfine
7,435 Recognized Expert Expert
I would try giving your "<a>" tags for your non-image links an "id" like this:
This is invalid. You cannot use an 'id' name more than once per page.

So if you want only one image to not have the blue outline, give it an id. If you have more than one that needs it removed, give them all a class name. Then, in the css:
#remove{
border:0
}

or, for a class
.remove{
border:0
}
Sep 11 '07 #5
Death Slaught
1,137 Top Contributor
This is invalid. You cannot use an 'id' name more than once per page.
(more in a moment)
How interesting I'm very curious to how you would be able to do this other wise, and I've never herd anything of not being able to use an "id" name more than once. Also I tried it on 30 different links, it worked fine.


Thanks, Death


PS - I'm subscribing so you can teach me a lesson ~_^ lol
Sep 11 '07 #6
drhowarddrfine
7,435 Recognized Expert Expert
Is there nothing I can do that's global that just says if a image within a href tag, dont apply the styles
I missed this part. Yes there is but I need to finish something else.
Sep 11 '07 #7
drhowarddrfine
7,435 Recognized Expert Expert
How interesting I'm very curious to how you would be able to do this other wise, and I've never herd anything of not being able to use an "id" name more than once. Also I tried it on 30 different links, it worked fine.


Thanks, Death


PS - I'm subscribing so you can teach me a lesson ~_^ lol
Read about the differences between a class and an id.
Sep 11 '07 #8
Death Slaught
1,137 Top Contributor
Read about the differences between a class and an id.
Ok well thats all fine, but as you can see here the "class" attribute is only used for aligning things, and the "id" attribute is used for changing the color of one thing and not others, I understand how it is used to specify one thing, 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?

Thanks, Death

PS - I know this post is gona come back to haughnt me, but then again thats what I get for challenging The ever so wise drhowarddrfine.
Sep 11 '07 #9
drhowarddrfine
7,435 Recognized Expert Expert
If you want all images inside a link to not have the border:
a:link img{border:0}
a:hover img{border:0}
Sep 11 '07 #10

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

Similar topics

22
5150
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
5862
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
4838
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
7027
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
1756
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
3880
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
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
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...
0
8976
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...
0
6740
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
5381
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
4053
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
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.