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?
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.