It's better when it's simple

User Tools

Site Tools


Switching to XHTML 5

If you want to switch to XHTML 5 and to a application/xhtml+xml content-type, here is what to do:


xmlns="" xml:lang="<?php echo $conf['lang'] ?>"

to the <html> tag and

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")
     || stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator") ) {
  header("Content-type: application/xhtml+xml");
  header("Vary: Accept");
} else {
  header("Content-type: text/html");

before the doctype in

  • ./lib/tpl/<template>/main.php
  • ./lib/tpl/<template>/detail.php
  • ./lib/tpl/<template>/mediamanager.php
  • ./inc/actions.php inside if($act == 'export_xhtml'){ for the “export_html” mode

Possible issues


In XML no other named entities than &lt;, &gt;, &quot; and &amp; should be used (otherwise it may lead to parsing errors, ie. the page won't be displayed at all).

Many entities in DokuWiki have been converted to their unicode or numeric entity equivalent, but some might be left.

JavaScript errors

There are quite a few JavaScript errors (documented in the bug tracker as well) when using DokuWiki with an XML content-type.

“XML parsers are permitted to silently remove the contents of comments. Therefore, you should not use comments to “hide” scripts or style sheets.”

<script type="text/javascript" charset="utf-8" ><!--//--><![CDATA[//><!--

Use this instead:

// doing something

Check plugins and templates

You should also be aware of the fact that plugins and templates may not take care of strictness or validity at all. So, if your DokuWiki installation uses any of these enhancements, you need to check separately and should make sure they produce valid XHTML and don't use no named entities.


tips/xhtml5.txt · Last modified: 2016-04-20 21:13 by ach

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki