Jump to content

W3c Error: Div As A Link


dakke
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...