Connecting Tech Pros Worldwide Help | Site Map

XHTML Doctype question and THANKS to the group.

  #1  
Old December 16th, 2005, 05:10 AM
Viken Karaguesian
Guest
 
Posts: n/a
Hello everyone,

I have a question about the XHTML doctype. I often times see this statement
included in the <html> tag:

<html xmlns="http://www.w3.org/1999/xhtml">

If I use the full standard XHTML doctype, do I need to add the extra html
statement or is just plain ol' <html> enough? I'm not sure what the
difference is or if it's required to use them together or not.

Also, as an aside, the latest site I'm working on is now entirely valid
XHTML Strict! After reading about XHTML at W3Schools.com, I realized that
what I was alreay following those standards (closing all the tags, etc). I
had already validated the site to the HTML 4.01 Strict standard, so I
inserted the XHTML Strict doctype and found that the entire site validated!
I'm very happy, since it was just a handful of months ago that I was totally
dependent on Microsoft Frontpage and WYSYWYG design and knew nothing about
code.

*Many thanks* to all the people on this list (and on
comp.infosystems.www.authoring.stylesheets, which many of you frequent) who
took the time to answer my questions and help me learn. Site scripting has
been a lot of fun for me and I'm looking forward to finding more web
projects to do.
--
Viken K.


  #2  
Old December 16th, 2005, 05:58 AM
Jukka K. Korpela
Guest
 
Posts: n/a

re: XHTML Doctype question and THANKS to the group.


Viken Karaguesian wrote:
[color=blue]
> I have a question about the XHTML doctype.[/color]

I hope you realize that in practical HTML authoring for the WWW, using
XHTML as the format of documents served to clients is an exercise in
futility.
[color=blue]
> I often times see this statement
> included in the <html> tag:
>
> <html xmlns="http://www.w3.org/1999/xhtml">[/color]

It is an attribute specification.
[color=blue]
> If I use the full standard XHTML doctype, do I need to add the extra html
> statement or is just plain ol' <html> enough? I'm not sure what the
> difference is or if it's required to use them together or not.[/color]

If you wish to play the XHTML game, you need to read the rulebook.

"The root element of the document must contain an xmlns declaration for
the XHTML namespace [XMLNS]. The namespace for XHTML is defined to be
http://www.w3.org/1999/xhtml."

http://www.w3.org/TR/xhtml1/#strict
(There is no conformance other that "strict conformance" defined in the
XHTML 1.0 specification. The word "strict" is there just to mislead you;
it has nothing to do with the Strict vs. Transitional document types.)
[color=blue]
> After reading about XHTML at W3Schools.com,[/color]

You probably got a few things wrong. The W3Schools site is unreliable,
and it certainly isn't authoritative.
  #3  
Old December 16th, 2005, 01:05 PM
Martin Honnen
Guest
 
Posts: n/a

re: XHTML Doctype question and THANKS to the group.




Viken Karaguesian wrote:

[color=blue]
> I often times see this statement
> included in the <html> tag:
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> If I use the full standard XHTML doctype, do I need to add the extra html
> statement or is just plain ol' <html> enough?[/color]

If you intend to use XHTML as real XML serving it with a Content-Type of
application/xhtml+xml or application/xml to browsers like Mozilla or
Opera then you need to make sure your elements are in the XHTML
namespace so that the browser recognizes them. Those browsers use XML
parsers which do not look at external DTDs thus you have to make sure
your markup declares xmlns="http://www.w3.org/1999/xhtml" itself.

--

Martin Honnen
http://JavaScript.FAQTs.com/
  #4  
Old December 16th, 2005, 01:25 PM
Lachlan Hunt
Guest
 
Posts: n/a

re: XHTML Doctype question and THANKS to the group.


Viken Karaguesian wrote:[color=blue]
> I have a question about the XHTML doctype. I often times see this statement
> included in the <html> tag:
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> If I use the full standard XHTML doctype, do I need to add the extra html
> statement or is just plain ol' <html> enough?[/color]

Although the W3C validator will not issue an error or even a warning if
you omit it simply because of the way it's declared in the DTD, it is
actually required for practical reasons. But for it to have any effect
whatsoever, the page needs to be viewed under XML conditions, by using
an XML MIME type. Do a search for XML MIME Types, application/xhtml+xml
and XML Namespaces for more information about using XHTML correctly.

As an experiment, to see the effect for yourself, make a small XHTML
document, give the file a .xhtml or .xml file extension and load the
file from your local file system in a browser like Firefox. (On most
systems, these file extensions are commonly associated with the XML MIME
types: application/xhtml+xml and application/xml, respectively. But
beyond this, file extensions are essentially meaningless in the context
of the web)

When the above xmlns attribute is included, your browser should know
that the elements belong to the XHTML namespace and render them
appropriately. Without it, the browser won't recognise the elements as
XHTML elements and, in the case of Firefox and some other browsers, will
render a pretty-printed XML tree.

Theoretically, with a validating XML parser, the xmlns attribute
wouldn't be necessary, but most browsers (except for IE) don't use a
validating XML parser anyway; and certainly no browser I know of that
actually supports XHTML uses one.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
  #5  
Old December 16th, 2005, 02:25 PM
Viken Karaguesian
Guest
 
Posts: n/a

re: XHTML Doctype question and THANKS to the group.


Thanks for replying. I tried your experiment and saw the results just
as you said they would be.

Is using the xhtml doctype considered "overkill" for a website and only
used when actually needed? Should I just stick to the html 4.01 strict
doctype and forget about xml unless I specifically need to use it?

I'm just trying to figure out what's best. Since xhtml seems to be a
higher standard, I figured that validating a website to that standard
would make it "bullet-proof", so to speak.

Viken K.

  #6  
Old December 16th, 2005, 02:57 PM
Martin Honnen
Guest
 
Posts: n/a

re: XHTML Doctype question and THANKS to the group.




Viken Karaguesian wrote:

[color=blue]
> Is using the xhtml doctype considered "overkill" for a website and only
> used when actually needed? Should I just stick to the html 4.01 strict
> doctype and forget about xml unless I specifically need to use it?[/color]

Many consider serving XHTML as text/html unnecessary or even harmful
<http://www.hixie.ch/advocacy/xhtml>
and therefore think HTML 4.01 is a better choice.



--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
SqlDataSource: No valid declarative parameter value for a datetime? Ken Cox [Microsoft MVP] answers 3 June 20th, 2007 03:45 AM
Doctype question from amateur Deborah answers 20 March 30th, 2007 12:55 AM
help, my program runs to fast! André answers 6 December 3rd, 2006 08:05 PM
Extending/Inheriting classes to produce valid XHTML from ASP.NETv1.1 Anthony Williams answers 8 November 18th, 2005 05:38 AM