dakke Posted November 3, 2009 Share Posted November 3, 2009 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 More sharing options...
Err Posted November 3, 2009 Share Posted November 3, 2009 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 More sharing options...
dakke Posted November 3, 2009 Author Share Posted November 3, 2009 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 More sharing options...
jlhaslip Posted November 3, 2009 Share Posted November 3, 2009 The link (anchor tag) is an in-line element and can not contain a block level element inside itself. Div's are block level tags. Link to comment Share on other sites More sharing options...
Ingolme Posted November 3, 2009 Share Posted November 3, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.