You are here: Re: Anchor outside div not validating « HTML « IT news, forums, messages
Re: Anchor outside div not validating

Posted by Ben C on 01/08/08 21:53

On 2008-01-08, Fister <vil_ikke@have_spam.dk> wrote:
> Since anchors are inline elements and divs are block elements the validation
> doesn't permit me placing an anchor around a div like the following:
>
><div id="containers">
> <a href="page.html">
> <div class="container">
> <img alt="image" src="image.jpg" />
> <div class="heading">Heading</div>
> <div class="text">Text</div>
> </div>
> </a>
></div>
>
> I want for the heading and text to change color whenever the mouse is above
> the image, heading or text. I also want for the image, heading and text to
> be below eachother so that's why I'm using divs and not spans.
>
> Isn't this common code

Probably.

> and how do I make it valid?

You could use span instead of div, and set

.container, .heading, .text { display: block }

The caveat is that this won't look good on non-CSS browsers.

Or you could use several <a> elements-- one inside each of the block
elements.

<div class="heading"><a href="page.html">Heading</a></div>

etc.

How are you doing the colour change? If you use a:hover { color: green }
then it should all go green when you hover on any part of it, since when
you hover on something you also hover on its descendents.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация