drawing a blank (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets



Message


lilblackgirl -> drawing a blank (2/15/2007 9:36:34)

This is basic, but my brain won't work this morning.

in my stylesheet, if i set my basic link settings as so:



a, a:visited {
color: #ffffff;
text-decoration: underline;
}

a:hover {
color: #000;
background-color: #7a7f9a;
text-decoration: none;
}



and i have a graphic that links to an outside address, by default, the link settings above will apply to the graphic. How do i set the link settings for the graphic to not do this? I just want to be able to hover and click without any style settings being applied to the graphic. I thought of setting it to a class/id, but i shouldn't have to set up a special class/id to counter the default settings, should I?

I know this is a silly question, but i'm drawing a blank.




Tailslide -> RE: drawing a blank (2/15/2007 10:31:12)

Yes you need to set up a specific class for the different links. Unless you tell it otherwise it will apply the default settings.




mtfm -> RE: drawing a blank (2/15/2007 10:34:41)

If the image is a link, the style will be applied unless you add something else.

instad of an id or class, couldn't you apply css to the img tag? And as long as that declaration was after the link ones, it should be ok.




Tailslide -> RE: drawing a blank (2/15/2007 10:43:01)

Adding inline CSS is a bad idea for the vast majority of cases (can't think of an exception off hand). You'd lose the ability to reuse and change the class throughout the site. Just declare a class in the stylesheet for the image links.




mtfm -> RE: drawing a blank (2/15/2007 11:10:10)

I didn't mean apply it inline, though I see how one read it that way.

After the other declarations (and in the external stylesheet), couldn't you make a declaration that all attributes with the img tag are not underlined, etc? And as long at it was in the stylesheet after the link declarations, it would apply to all images, even those with a link.




Tailslide -> RE: drawing a blank (2/15/2007 11:19:30)

I find it more reliable to actually declare a class for this sort of thing - you can specify img {border:0} for all images and that does away with the standard link border which may be all you need. But if you need to do any more than that then you're better off with an actual class as links can be a bit tricky at times (that may well just be me though!).

edit: should be border:none;




lilblackgirl -> RE: drawing a blank (2/15/2007 12:04:38)

But is creating a class, just for the sake of cancelling out all of the default link settings the correct way to do it? And how do those settings applied to a graphic as opposed to text differ?

For example, on hover, if my default link setting changes the background color, it's doing the same on the graphic.




Tailslide -> RE: drawing a blank (2/15/2007 12:42:29)

Yes it's correct or I wouldn't suggest it.

You can try the border:none (not border:0 - in too much of a hurry) applied to images and see if that works.

If not set up a class and add it to the graphics or any other link you don't want to have the default colours/styles to cancel the defaults out. This is how CSS works - you set up defaults then add in the exceptions as classes or ids.




jaybee -> RE: drawing a blank (2/15/2007 13:11:13)

quote:

But is creating a class, just for the sake of cancelling out all of the default link settings the correct way to do it?
How else are you going to do it? You've told it to apply xyz to all links, now you want one that doesn't use xyz so you have to tell it, in this case, use abc instead.




lilblackgirl -> RE: drawing a blank (2/15/2007 15:22:32)

quote:

How else are you going to do it?


I don't, which is why i was asking. i felt like i was overlooking something obvious, but if that's the way it's gotta be done, then that's how i'll do it.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
5.859375E-02