I'm having some trouble getting CGI.pm to output to HTML5 instead of XHTML 1.0 or HTML 4.01. When I try "HTML5"
or "HTML 5"
as the -dtd
argument in start_html()
I get a document in HTML 4. I've also tried importing :HTML5
, but that doesn't seem to work either. Any advice?
views:
290answers:
2Patch the module to add support for HTML5 … or just output a Doctype manually, then use it as normal. If it is valid XHTML 1.0 or HTML 4.01 then it is valid HTML 5.
The correct doctype for HTML 5 is just "html", not "html5" or "html 5", and does not use a DTD. CGI.pm only supports well-formed DTDs, not arbitrary strings. Since the HTML 5 doctype does not include a well-formed DTD, CGI.pm (as of the current version, 3.49) does not support the HTML 5 doctype.
Using CGI.pm's HTML-generation functions is generally frowned upon these days. Templating systems such as Template::Toolkit or HTML::Template are preferred for their ability to cleanly separate your code's logic from the formatting of its output. They also, incidentally, allow you to specify whatever doctype and code to whatever version of (X)HTML you choose.