# Doctype Helper

Valid HTML and XHTML documents should include a `DOCTYPE` declaration. Besides being difficult to remember, these can also affect how certain elements in your document should be rendered (for instance, CDATA escaping in <script> and <style> elements.

The `Doctype` helper allows you to specify one of the following types:

- `XHTML11`

- `XHTML1_STRICT`

- `XHTML1_TRANSITIONAL`

- `XHTML1_FRAMESET`

- `XHTML_BASIC1`

- `HTML4_STRICT`

- `HTML4_LOOSE`

- `HTML4_FRAMESET`

- `HTML5`

You can also specify a custom doctype as long as it is well-formed.

The `Doctype` helper is a concrete implementation of the Placeholder helper.

## Doctype Helper Basic Usage

You may specify the doctype at any time. However, helpers that depend on the doctype for their output will recognize it only after you have set it, so the easiest approach is to specify it in your bootstrap:

    $doctypeHelper = new Zend_View_Helper_Doctype();
    $doctypeHelper->doctype('XHTML1_STRICT');

And then print it out on top of your layout script:

    <?php echo $this->doctype() ?>

## Retrieving the Doctype

If you need to know the doctype, you can do so by calling `getDoctype()` on the object, which is returned by invoking the helper.

    $doctype = $view->doctype()->getDoctype();

Typically, you'll simply want to know if the doctype is XHTML or not; for this, the `isXhtml()` method will suffice:

    if ($view->doctype()->isXhtml()) {
        // do something differently
    }

You can also check if the doctype represents an HTML5 document

    if ($view->doctype()->isHtml5()) {
        // do something differently
    }