Class it_html:

/**
 * Return HTML header on first call or empty string on subsequent calls
 *
 * @param args... any number of assoc arrays and strings. strings will be content of <head>
 * @param $p['content-type']  content type (default: "text/html; charset=iso-8859-1")
 * @param $p['headers']       Array of HTTP headers (e.g. [ 'Vary' => "User-Agent,Accept-Language" ])
 * @param $p['cssinline']     stylesheet to be put in header
 * @param $p['description']   data for <meta name="description"> tag
 * @param $p['keywords']      data for <meta name="keywords"> tag
 * @param $p['stylesheets']   array mediatype => url of styleshests
 * @param $p['title']         content of <title>, will be html encoded
 */
function head($args = array())
{
    if (!$this->head_sent++)
    {
        list($data, $p) = it_parse_args($args);

        $p += $this->p;
        $this->p = ($p += array('content-type' => "text/html; charset={$p['charset']}"));

        $header = $p['show_content_type'] ? meta(array('http-equiv' => "Content-Type", 'content' => $p['content-type'])) : "";

        # Enable latest IE mode
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
            $header .= meta(array('http-equiv' => "X-UA-Compatible", 'content' => "IE=edge"));

        foreach(array('description', 'keywords') as $name)
            if (!empty($p[$name]))
                $header .= meta(array('name' => $name, 'content' => $p[$name]));

        # Add favicon
        if ($p['favicon'])
            $header .= tag('link', array('rel' => "shortcut icon", 'href' => $p['favicon']));
        else if ($p['show_favicon'] && @file_exists($_SERVER['DOCUMENT_ROOT'] . '/favicon.ico'))
            $header .= tag('link', array('rel' => "shortcut icon", 'href' => U("/favicon.ico")));

        foreach((array)$p['stylesheets'] as $type => $url)
            $header .= tag('link', array('rel' => "stylesheet", 'type' => "text/css", 'href' => $url) + (is_int($type) ? array() : array('media' => $type)));

        if (!empty($p['cssinline']))
            $header .= tag('style', array("\n" . preg_replace(array('/\s*\/\*[^\*]+\*\//Um', '/\s*\{\s*/', '/;\s+/'), array('', '{', ';'), $p['cssinline'])));

        $header .= $p['head'] . ($p['title'] ? tag('title', Q($p['title'])) : "");

        if($this->p['htmltype'] == "xhtml-mobile" && strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator'))
            header("Content-Type: application/xhtml+xml; charset={$this->p['charset']}"); # for validation
        else if (!headers_sent()) # prevent warnings when ED() in use
        {
            header("Content-Type: " . $p['content-type']);
            foreach ((array)$p['headers'] as $key => $value)
                header("$key: $value");
        }

        $js = isset($p['jsenv']) ? "var env = " . itjs::serialize($p['jsenv']) . ";\n" : '';
        $js .= $this->_itjs($p['jsinline']);

        if ($js)
            $data .= $this->js(array(self::_cleanup($js, $p['charset'])));

        return tag('head', $header, $data);
    }
}