Old 18-07-2006, 13:26   #1 (permalink)
Scott
sanddancer
 
Scott's Avatar
 
Join Date: Feb 2004
Location: South Shields
Posts: 2,924
Send a message via MSN to Scott
css/xhtml linkage

Probably really simple/easy but it's not validating with w3c the way I'm currently doing it.

Ok, how do I go about linking an image, that is set as the background in the css.
e.g.

background: url(../images/marsbar.jpg);
__________________
  Reply With Quote
Old 18-07-2006, 15:02   #2 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Try - background: url("../images/marsbar.jpg") no-repeat top left #FFF; - for example. You're using the shorthand.

If you just want to specify and image, use "background-image: blah;"

Maybe...I've never had a problem.
  Reply With Quote
Old 18-07-2006, 15:19   #3 (permalink)
Scott
sanddancer
 
Scott's Avatar
 
Join Date: Feb 2004
Location: South Shields
Posts: 2,924
Send a message via MSN to Scott
thats not really my problem, I want to know how to link from the image thats in the background.

For example i have a div with an background image.

Not having anything else but the background image in the div how do i then attach a link to it?

I've been doing it this way:

<a href="blahblah.html"><div id="moreblah"></div></a>

It does make the entire DIV ino a link -- which is what I want, but its not allowed in the w3c?

The link below is what im on about, the Download CV and email I want linked.

Click

Another thing, in the "respected" section, why does it mess up in IE?...I've tried sorting it but without success.
__________________

Last edited by Scott : 18-07-2006 at 15:29.
  Reply With Quote
Old 18-07-2006, 15:43   #4 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Oh. <a> is an inline element, <div> is a block element. Inline elements may not contain block elements.

Image replacement to the rescue!

HTML Code:
<a href="mailto:you"><span>Email me!</span></a>

Code:
a { display: block; width: width-of-image-px; height: height-of-image-px; background: url(blah.gif) no-repeat blah blah blah; } a span { display: block; width: 0; height: 0; overflow: hidden; }
  Reply With Quote
Old 18-07-2006, 15:44   #5 (permalink)
Scott
sanddancer
 
Scott's Avatar
 
Join Date: Feb 2004
Location: South Shields
Posts: 2,924
Send a message via MSN to Scott
my bad, thanking you mr Pgo
__________________
  Reply With Quote
Old 18-07-2006, 15:51   #6 (permalink)
Scott
sanddancer
 
Scott's Avatar
 
Join Date: Feb 2004
Location: South Shields
Posts: 2,924
Send a message via MSN to Scott
...and how about the respected list?
__________________
  Reply With Quote
Old 18-07-2006, 15:56   #7 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Welcome.

How about it?
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8