How To Declare DOCTYPE And Encoding Using CGI.pm And PERL

Published Date Author: , Posted May 31st, 2011 at 10:10:26am

I found myself needing a specific doctype the other day and this is what I found…

First, get the correct doctype string from the W3C website list.
Then, simply use -dtd to specify it to CGI.pm during the call to start_html:

In addition, use -encoding to specify the character set for XHTML. It defaults to iso-8859-1 if not specified.
The encoding may also be set in the header using -charset like this (shown with the optional -cookie parameter):

Documentation for CGI.pm

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.