I'm getting HTML validation errors from some code generated by views when using the W3C's validation tools. I have my view set to display as unformatted fields. This is the code that's being generated (dev snapshot from yesterday):

<div class="view-content">
          
  <div class="views-field-title">
          <span class="field-content"><a href="/content/another-bit-important-news">Another bit of important news.</a></span>
  </div>
  
  <div class="views-field-teaser">
          <span class="field-content"><p>Lorem ipsum dolor sit amet.</p></span>
  </div>

</div>

And the validation error:
"document type does not allow element "p" here; missing one of "object", "ins", "del", "map", "button" start-tag."

I think because of the use of the <p> tag within a <span>.

Comments

merlinofchaos’s picture

Status: Active » Closed (works as designed)

If you select a field to display 'inline' then it will appear within a span. If you do not check this, it will appear within a div. The body/teaser fields will all have p tags, because that's how Drupal works.

Therefore, it is your responsibility to ensure that you do not mark fields 'inline' that cannot appear within a 'span' tag if you want your code to w3c validate. This setting is completely optional, it's not a bug.

mrfelton’s picture

I have tried as unformatted, and as a list, without the 'Display as inline' checkboxes checked for any of my fields, and it is still producing HTML like this

novica’s picture

I run into the same issue. It seems that using a table style fixes the html validation.