View Full Version : link in css?


fruitcake
11-13-2003, 08:33 PM
How can I link an image when I put it in with css?

HTML:
<div class="storelogo">
</div>

CSS:
.storelogo {
width: 104px;
height: 55px;
background-color: #030060;
background-image: url(images/logo.gif);
background-repeat: no-repeat;
background-attachment: fixed;
float: left;
}

How can I make the image clickable to link back to "main.html"?
Thanks

pb&j
11-13-2003, 09:33 PM
to make a link, you have to use normal html coding. css just formats, it does not create an actual link.

fruitcake
11-13-2003, 10:20 PM
... that doesn't answer my question- how do I link it?

kittycat
11-13-2003, 10:37 PM
You can't link an image in CSS, basically what pb&j said. You have to include the image as part of the HTML of your page and link it as you normally would.

pb&j
11-13-2003, 11:12 PM
Originally posted by fruitcake
HTML:
<div class="storelogo">
</div>

HTML:
<div class="storelogo">
<a href="whatever.html"><img src="imagename.gif" border="0"></a>
</div>

Neffie
11-14-2003, 12:14 AM
There has to be a way. We have an assignment where we have to create a splash page for our websites and the link to the website has to be an image. The teacher said our images must be embedded using CSS. He has taught this course for many years at college and therefore if there was not a way he would not keep assigning this.

pb&j
11-14-2003, 02:32 AM
to re-itterate...

css may format a link, it cannot be used to create a link itself.

HTML = Hyper Text Markup Language.
the term HYPER means link.

CSS = Cascading Style Sheet.
the term STYLE means just that, the style of the object.

CSS may be used to assign a background image to an area.
CSS may be used to assign a style of a linked image.
CSS itself cannot link an object to another place.

you should talk to your teacher to have him explain exactly what he is wanting in your assignment. he may have "worded" the assignment a bit wrong or something.

Neffie
11-14-2003, 03:14 AM
I know what HTML and CSS stand for.

We don't want to link directly in CSS. The linking can be in html, it is just that the code does not validate when you have a div in a link tag.

Neffie
11-14-2003, 07:16 PM
Found out how to do it! You give your a href tag a class and then embedd an image in that class!

fruitcake
11-14-2003, 07:18 PM
HA! And you said we had to use the img tag.

<a href="main.html" class="storelogo"></a>

pb&j
11-14-2003, 11:19 PM
i said that to create a link, html coding had to be used.
in your example, the A tag is an html tag for linking.

i said that css is used to format objects, not create links.
in your example again, the class is formatting the link, not creating it.

Neffie
11-15-2003, 01:32 AM
Yah and we were asking how to create an image that links when the image has to be in css. We knew that the link had to be in html, it was just getting it to work with css that was the problem and no one answered just kept saying css was to format, which answers nothing.

You guys kept saying the image had to be
in HTML too which it doesn't.

Please use the Edit button instead of replying within 5 minutes of posting
-Moderator

Rosey
11-15-2003, 02:16 AM
Well you know, the people answering the posts don't know it all and I don't think anyone has ever claimed to. Everyone tried to answer to the best of their knowledge.

We all learned something new (well I did), leave it at that, no need for the attitudes.

MaGiCSuN
11-15-2003, 11:18 AM
i'm closing this thread.

fruitcake: your code is still html
Neffie: i believe fruitcake was asking the question... not 'we'

if you want clear answers, then also ask a clear question. Your title says "link in css" not "link together with css" so we think you want to make a link INSIDE the css coding, wich isn't possible... we are not mind readers, we only trying to help.

Love,
Mirna