Jump to content

W3c Error: Div As A Link


dakke

Recommended Posts

Hi,A quick question:Why do I get a W3C error when I make a link of a div as in:

<div id="topDiv"><a href="thispage.php"><div id="justanotherdiv">some text</div></a></div>

With error:

"A closing tag </aaa> is missing before the opening of another tag <bbb>. This is probably due to a implicit close of the <aaa> tag due to the opening of the <bbb> tag. "
Is such not allowed, and how does one make a link of an entire div?
Link to comment
Share on other sites

You cannot nest a div in a link tag. I mean, you can but it's not valid code. A work around for that is using span instead of a div, or if you want a clickable box, make the link as big as you want it though CSS.

Link to comment
Share on other sites

You cannot nest a div in a link tag. I mean, you can but it's not valid code. A work around for that is using span instead of a div, or if you want a clickable box, make the link as big as you want it though CSS.
Thanks, will give it a go, much appreciated...
Link to comment
Share on other sites

You can get the effect you want by turning the <a> element into a block itself:

<a href="thispage.php" id="justanotherdiv">some text</a>

.justanotherdiv {  display: block;  width: 200px;  background-color: blue;}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...