XHTML help!

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

XHTML help!

Postposted on Sat Feb 21, 2009 11:32 am

Here's my blog. Notice the two images on the right side of the banner, that change opacity as you mouse over them.
http://ritchan.dasaku.net

http://validator.w3.org/check?uri=http% ... aku.net%2F
W3C says <div> inside <a> is illegal. The rest of the errors are easily fixed... but I like to have my theme compliant, at least. How do I achieve the same thing in a compliant way?
Mothership: Thuban 1055T@3.7GHz, 12GB DDR3, M5A99X EVO, GTX470+Icy Vision Rev.2@840/3800, Vertex 2E 60GB
Supply ship: Sargas@2.8GHz, 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Macbook Air Ivy Bridge
Crayon Shin Chan
Minister of Gerbil Affairs
 
Posts: 2241
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia

Re: XHTML help!

Postposted on Sat Feb 21, 2009 12:24 pm

Switch the <div> and <a> around?
Image
The Model M is not for the faint of heart. You either like them or hate them.

Gerbils unite! Fold for UnitedGerbilNation, team 2630.
Flying Fox
Gerbil God
 
Posts: 24422
Joined: Mon May 24, 2004 2:19 am

Re: XHTML help!

Postposted on Sun Feb 22, 2009 1:23 pm

Flying Fox wrote:Switch the <div> and <a> around?

++
This won't actually effect anything, but will bring you closer to standards compliance. Unless, you want the whole block to be clickable, in which case, take what you've specified for the div in terms of margins, borders and padding, and specify it for a.

Additionally, marking things up appropriately in the first place reduces how much fixing you have to do later. (e.g.: &amp; instead of &.)
The best things in life are free.
http://www.gentoo.org
Guy 1: Surely, you will fold with me.
Guy 2: Alright, but don't call me Shirley.
titan
Grand Gerbil Poohbah
 
Posts: 3276
Joined: Mon Feb 18, 2002 7:00 pm
Location: Great Smoky Mountains

Re: XHTML help!

Postposted on Sun Feb 22, 2009 1:38 pm

I've been doing a little more looking into your source, and you didn't specify the language either:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
The best things in life are free.
http://www.gentoo.org
Guy 1: Surely, you will fold with me.
Guy 2: Alright, but don't call me Shirley.
titan
Grand Gerbil Poohbah
 
Posts: 3276
Joined: Mon Feb 18, 2002 7:00 pm
Location: Great Smoky Mountains

Re: XHTML help!

Postposted on Mon Feb 23, 2009 1:39 pm

OK so I switched the div and a around. Now they're unclickable (there's no link). I haven't specified any margins, borders or padding for the div class, but I have specified its width and height. I apply that to <a>. Boom, the unclickable image disappears.

Is there another way of doing this? EDIT: fixed by setting display:block. I found that works sometimes for disappearing elements.
Mothership: Thuban 1055T@3.7GHz, 12GB DDR3, M5A99X EVO, GTX470+Icy Vision Rev.2@840/3800, Vertex 2E 60GB
Supply ship: Sargas@2.8GHz, 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Macbook Air Ivy Bridge
Crayon Shin Chan
Minister of Gerbil Affairs
 
Posts: 2241
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia

Re: XHTML help!

Postposted on Mon Feb 23, 2009 3:28 pm

1. Take the styling you applied in your stylesheet, and move it from the div to the anchor tag.
2. Remove the background-image from the style.
3. Add an img tag within the anchor, and set the src pointed to the original background image.
4. Style new img tag as needed, borders etc...

Verify functionality, revalidate with w3.

Note, this is based on the original markup when you first posted.
Cubical 10
I only know enough to be dangerous.

Do ubuntu? pfsense
cubical10
Gerbil First Class
 
Posts: 184
Joined: Fri Mar 03, 2006 2:52 pm
Location: Montreal


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 2 guests