It’s all about quality
Sitecore is a rich platform with powerful web content management capabilities. One of the standard available features are validators that automatically execute as a part of the publishing workflow. One of the validators that is executed in that process is the Full Page Xhtml validator that checks whether the whole page that is to be published is compliant with XHTML. At first such check seems very useful: after all if your website has been delivered with valid HTML, you will very likely want to keep it that way. Using valid HTML means not only that your web pages will render faster but they will also be rendered as intended by the designers. Invalid HTML often results in browsers using quirks mode rendering where the browser tries to make best out of your HTML. In many cases this leads to rendering inconsistencies across the different browsers but also comparing to the original design. While it almost seems like a no-brainer to use the XHTML validator to validate your pages before publishing, there is one problem with it.
XHTML: do you really want it?
The Full Page Xhtml validator has been designed to validate the conformance of your website with the XHTML standard. The problem with XHTML is that it’s based on XML which isn’t very forgiving and theoretically, whenever there is an error somewhere in the XML, the only thing that is rendered is the error message.
The XHTML standard has been originally published in 2000 and many things have changed on the web since then. As the web evolved and new demands emerged, the HTML5 standard has been published. HTML5 not only added new capabilities to HTML but also changed the main philosophy behind HTML. Rather than using the strict XML grammar as XHTML did, HTML5 allows developers to decide for themselves whether they want to have their HTML XML-compliant or not. Either way HTML5 documents are not served as XML and minor errors in the grammar are forgiven without the visitors even noticing them. HTML5 allows for greater flexibility on the web, but also to an issue in Sitecore 8 XP.
Inconvenient HTML5 in Sitecore 8 XP
Consider the following webpage:
<!doctype html> <html> <head> <title>@Html.Sitecore().Field("Title")</title> </head> <body> <p>Hello world</p> </body> </html>
It’s a perfectly valid HTML5 document. If you would however implement this HTML as a layout in Sitecore and would try to approve an item for publishing, all you would see was the following error:
Disabling XHTML validation
The good news is that Sitecore is a highly customizable platform and nearly everything about it can be configured to meet your needs. This applies also to controlling which validators should be executed as a part of the publishing approval process. If you want more flexibility in the HTML that you are using on your website you can disable the XHTML validation for the publishing approval process. To do this open the Content Editor and in the tree view navigate to the /sitecore/System/Settings/Validation Rules/Global Rules item. Then, in the Validation section, go to the Workflow field and remove the Full Page Xhtml validator from the list of selected validators.
Sitecore tries to help you maintain the quality of your website by automatically validating your HTML when approving items for publishing. If you’re using non-XHTML compliant HTML on your website, the validation process will return an error and will prevent you from publishing items. The XHTML validation process can be disabled giving you the maximum flexibility with regards to building the HTML for your website.