Monday 15 August 2011

html - Is putting a div inside an anchor ever correct? -


I've heard that putting a block element inside an inline element is an HTML error:

 < Code> & lt; A href = "http://www.mydomain.com" & gt; & Lt; Div & gt; We have a problem here, you see, an anchor element is an inline element, and the div element is a block level element & lt; / Div & gt; & Lt; / A & gt;  

But what if you style the external anchor in the stylesheet as display: block ? Is it still wrong? The HTML 4.01 seems to be on the spec:

Style sheets provide means to specify the rendering of arbitrary elements, including whether the element is provided as a block or inline is. In some cases, such as an inline style for list elements, it may be appropriate, but generally, the authors are so discouraged from overriding the traditional interpretation of HTML elements like this.

Anyone else have more suggestions about this issue?

Depending on the version of HTML you are eating:


No comments:

Post a Comment