XHTML 1.1 and Tag

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I hope this it the right group as I couldn't find a more suitable match for
the question.

I don't see anywhere in the XHTML 1.1 spec that allows the use of the "name"
attribute for the <A> tag.  We used to use those for anchors but if they
aren't in the spec, what are we supposed to use to achieve the same effect?


Re: XHTML 1.1 and Tag

Quoted text here. Click to load it

text/html is a perfectly valid MIME type.


This document even clarifies that "[XHTML1] defines a profile of use of
XHTML which is compatible with HTML 4.01 and which may also be labeled as


As stated on this W3C document, "[t]he use of 'text/html' for XHTML should
be limited for the purpose of rendering on existing HTML user agents." This
is exactly why I use it, and it is perfectly valid to do so.

In actuality, I wrote the following to minimize its use:


if ((preg_match("/application\/xhtml\+xml/i", $_SERVER['HTTP_ACCEPT'])) ||
(preg_match("/version=xhtml11(&[a-z0-9]*|$)/", $_SERVER['QUERY_STRING'])))
  header("Content-Type: application/xhtml+xml;charset=utf-8\n");
  header("Content-Language: en\n\n");
  echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd \">\n";

else {
  header("Content-Type: text/html;charset=utf-8\n");
  header("Content-Language: en\n\n");
  echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd \">\n";


The regex for "version=xhtml11" is simply an override; for example, if I
want to validate my document, I append "?version=xhtml11" onto the URI
(since the W3C validator doesn't include application/xhtml+xml in its http-
accept header).


Re: XHTML 1.1 and Tag

Eric B. Bednarz wrote:

Quoted text here. Click to load it

Try this with just strpos()...

    function goodbrowser () {
        $ac = strtolower(getenv('HTTP_ACCEPT'));
        $ua = getenv('HTTP_USER_AGENT');

        # Netscape 6 can't properly handle XHTML
        if (substr_count($ua,'Netscape6') > 0 ) { return false; }
        # Wget can (well, it doesn't care!), but doesn't list it
        elseif (substr_count($ua,'Wget') > 0 ) { return true; }
        # Any browsers that don't specificially list XHTML, use HTML
        elseif (substr_count($ac,'application/xhtml+xml') == 0) { return false; }

        # Otherwise we need to compare 'q' values.
            $xhtml_q = 1; $html_q = 1;

(preg_match("/application\/xhtml\+xml\s*;[^,]*\bq\s*=\s*([\d\.]+)/",$ac,$m)) {
$xhtml_q = $m[1]; }

            if ( preg_match("/text\/html\s*;[^,]*\bq\s*=\s*([\d\.]+)/", $ac, $m)
              || preg_match("/text\/\*\s*;[^,]*\bq\s*=\s*([\d\.]+)/",   $ac, $m)
              || preg_match("/\*\/\*\s*;[^,]*\bq\s*=\s*([\d\.]+)/",     $ac, $m)
            ) { $html_q = $m[1]; }

            if ($xhtml_q >= $html_q) { return true; }
            else { return false; }

Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

Site Timeline