Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- hyperlinking a div


lucy24 - 12:45 am on Oct 31, 2012 (gmt 0)


Why did you decide to not apply something like that

I don't see how it would have helped. There's nothing wrong with having a link inside a div; the no-no is putting further block-level elements inside a link. The overall structure in my case would have been

<div style blahblah, including "text-align: right">
<a href = "link here">
<div style more blahblah, including "display: inline-block; text-align: center;">
<p style blahblah>Text here</p>
<p style blahblah><img src et cetera></p>
</div>
</a>
</div>


To make sure I wasn't remembering wrong, I fed the snippet into the w3 validator using the "HTML fragment" option. It was perfectly happy with the "onlick" version. (It was attached to the inner div, which is a visible unit.) But when I tried the "a href" version, it predictably spat out an error, with explanation
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

Again: doing it wrong would have worked. But you can't get in the habit of doing things you aren't supposed to do, just because they happen to work.


Thread source:: http://www.webmasterworld.com/css/4513519.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com