XHTML 1.1 and <A> Tag

S

Shawn B.

Greetings,

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?


Thanks,
Shawn
 
L

Leif K-Brooks

Shawn said:
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?

Unless you're doing something fancy with MathML or other XML dialects
mixed with HTML, there's very little reason XHTML 1.1 or even 1.0 over
HTML 4.01. XHTML doesn't even work in a popular web browser (Internet
Explorer) without a false mime type.

But, to answer your question, you use the ID attribute of any element.
See
<http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-id>.
 
S

Shawn B.

Thanks for both replies... I should have guessed... I saw that in the spec
(as a part of Common) but I didn't piece it together immediately...


Thanks,
Shawn


Leif K-Brooks said:
effect?

Unless you're doing something fancy with MathML or other XML dialects
mixed with HTML, there's very little reason XHTML 1.1 or even 1.0 over
HTML 4.01. XHTML doesn't even work in a popular web browser (Internet
Explorer) without a false mime type.

But, to answer your question, you use the ID attribute of any element.
See
<http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-id>.
 
S

Stephen T. Fox

In brucie <[email protected]> typed:
:| in post: <:| "Shawn B." <[email protected]> said:
:|
:| > I hope this it the right group
:|
:| nope. try alt.right
:|
:| > I don't see anywhere in the XHTML 1.1 spec that allows the use of
:| > the "name" attribute for the <A> tag.
:|
:| "name" is icky poo. use id.
:| http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-4.10
:|
:| --
:| b r u c i e

also, just cuz I'm a smartass, use lower case <a>

sorry about that, just got the urge...
 
G

Geoff Ball

XHTML doesn't even work in a popular web browser (Internet
Explorer) without a false mime type.

Yes it does. XHTML 1.0 (all versions) can correctly utilize the text/html
MIME type.

Regards,
Geoff
 
G

Geoff Ball

Which is a false mime type.

text/html is a perfectly valid MIME type.

<http://www.ietf.org/rfc/rfc2854.txt>

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
text/html."

<http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/#text-html>

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:

<?php

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

Regards,
Geoff
 
E

Eric B. Bednarz

Geoff Ball said:
text/html is a perfectly valid MIME type.

[for XHTML]

The only major point this informational note happens to clarify is that
the IETF HTML WG closed in '96.
that "[XHTML1] defines a profile of use of
XHTML which is compatible with HTML 4.01

Sure; this so-called compatibility proves that *not* taking W3C specs
seriously will make your implementations bulletproof forward-compatible
with any future science fiction prose.
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");

Kewl. It would never have occurred to me to look up a string using a
regular expression. But since redundancy at the cost of resources for
the sake of accomplishing futility seems to be the topic of this
thread...

Anyway, I wrote the following:

if(strpos($_SERVER['HTTP_ACCEPT'],'text/plain'))
header('Content-Type: text/plain; charset=us-ascii');

It works!!!
 
B

brucie

in post: <
Eric B. Bednarz said:
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");

very

if(strpos($_SERVER['HTTP_ACCEPT'],'text/plain'))
header('Content-Type: text/plain; charset=us-ascii');

It works!!!

it may work but it doesn't look as impressive or pervade the reader with
awe.
 
S

Spartanicus

Geoff Ball said:
text/html is a perfectly valid MIME type.

Validity doesn't come in to it.

text/*HTML* is a *false* mime type if the document is *XHTML*
 
A

Andy Dingley

Shawn B. said:
I don't see anywhere in the XHTML 1.1 spec that allows the use of the "name"
attribute for the <A> tag.

Use XHTML 1.0 Transitional.


I can think of no good reason to go to 1.1

I can think of no good reason, other than teaching the completely
naive, to go for a Strict DTD.

Many people (myself excluded) claim there is no reason to even go for
XHTML, rather than a HTML 4.01 DTD.



We now return you to our scheduled Appendix C flamewar.
 
E

Eric B. Bednarz

Many people (myself excluded) claim there is no reason to even go for
XHTML, rather than a HTML 4.01 DTD.

Some people (myself included) claim that there is no reason to go for
any declaration of a formalised syntax when the end user software
doesn't care about it anyway, as it is unambiguously the case for
text/html.

Having said that, I nearly always do, because it allows me to use SGML
tools in the authoring process. Well, admittedly I also fear the
rapidly growing number of half-educated web standards subscribers who
take any break from playing counterstrike to send your clients a link to
the W3C validator accompanied with Mabusian prophecies of how their site
will very soon be like totally not forward compatible and stuff.
We now return you to our scheduled Appendix C flamewar.

There's nothing wrong with Appendix C (of the Jargon File :).
 
T

Toby A Inkster

Eric said:
Kewl. It would never have occurred to me to look up a string using a
regular expression.

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.
else
{
$xhtml_q = 1; $html_q = 1;

if (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; }
}
}
 
E

Eric B. Bednarz

Toby A Inkster said:
Try this with just strpos()...

Oh sure, if you wanted to do something *sensible* with the accept header
it wouldn't suffice. There was no such attempt in the original code.

BTW, when I wrote 'It works' I somehow hoped it was self-evident enough
that a (sensible) accept header of an HTML UA would not (anymore).
 
O

Owen Jacobson

Toby said:
function goodbrowser () {

....snip...

# Wget can (well, it doesn't care!), but doesn't list it
elseif (substr_count($ua,'Wget') > 0 ) { return true; }

Strictly speaking, wget lists *everything*, at least in my copy:

$ wget http://host/

Ethereal reports:
Sent:
GET / HTTP/1.0
User-Agent: Wget/1.8.2
Host: host
Accept: */*
^^^
Connection: Keep-Alive

In this case, and in the absence of *either* text/html or
application/xhtml+xml in the Accept header, it might be wiser to judge
which of the two is higher "quality", rather than basing it on User-Agent.
# Any browsers that don't specificially list XHTML, use HTML
elseif (substr_count($ac,'application/xhtml+xml') == 0) { return false; }

Perhaps:
/* this could be MUCH more efficient, but it gets the idea across */
elseif ((substr_count ($ac, 'application/xhtml+xml') == 0) &&
(substr_count ($ac, 'text/html') > 0)) {
return false;
} elseif ((substr_count ($ac, 'application/xhtml+xml') > 0) &&
(substr_count ($ac, 'text/html') == 0)) {
return true;
} elseif ((substr_count ($ac, 'application/xhtml+xml') == 0) &&
(substr_count ($ac, 'text/html') == 0) &&
/* should also account for text/*, application/* */
(substr_count ($ac, '*/*') > 0) {
return /* whichever is higher quality */;
}
# Otherwise we need to compare 'q' values.
else
{
....snip...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top