Preferred Document Type

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

Threaded View
I am currently coding with the following Document Type simply because
it is used in the book I am using to learn HTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" ">
<html xmlns=" ">
 blah blah blah

I've read elsewhere that "you should always use"

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   " ">
 blah blah blah

My code validates using the first method and fails using the second.
The failures (so far) have been due to using a trailing / to close
certain tags such as <link blah blah blah />.

Is one method better than the other?  Better may be asking too much.
Is one method preferred over the other?


Re: Preferred Document Type


Quoted text here. Click to load it

Here's my views on this.
There are two sets of rules. One for the author, one for the browser.
The validator is the only thing that requires the author to make
things work properly. The problem is, the browser may not always
impliment exactly what it is supposed to be as the validator says it

People who write browsers, only look at certain factors. As I don't
think there is a real way for a writer to ensure that all events will
display as the web page author intended. Like he's going to write
50,000 test pages just to make sure it complies with the rules? I
don't think so.

Then they come around every year or so with "NEW" this and that
procedures. Changing tag attributes, adding new tags, deleting old
ones. The problem is, people don't like changing browsers just to keep
up with the advances so old browsers still work with the old system.

The way I see it, if it works the way you want it, and it validates at
least to the point where errors are few and really meaningless, hey,
go for it.

I don't think there is such a thing as a 100% compatible browser.

Re: Preferred Document Type

Quoted text here. Click to load it

Andy Dingley once said:

"HTML 4.01 Strict for the very long-term forseeable future.
_Ten_whole_years_ after HTML 4, we're just about in a state where we
can use it without problems. We're still nowhere near being able to
use XHTML 1.0 as it's meant to be."

Spartanicus said many things, here are some of the best on the subject:


I say, use 4.01 Strict for the moment and wait till the coast is clear
in the future before changing.


Re: Preferred Document Type

Quoted text here. Click to load it

IE 6, IE 7 and IE 8 don't understand XHTML. Try that in IE with
an .xhm or .xhtml extension or serve it properly as "application/xhtml

If you're using elements from other namespaces like MathML or SVG you
can use "content negotiation" and then use CSS to hide MathML and SVG
elements from legacy browsers. In this way you can make your content
more accessible for people with disabilities or different languages.

Re: Preferred Document Type

Call Me Tom kirjoitti seuraavasti:
Quoted text here. Click to load it

It's quite easy to convert xhtml code to html. Usually the main task is
changing self-closing tags like <link blah blah /> to <link blah blah>
anb <br /> to <br> (OT: <br> should be avoided, play with marginc etc.).

Quoted text here. Click to load it

As said, use html strict for now. IE family understands it better
(better, not well).

Ari /

Re: Preferred Document Type

Quoted text here. Click to load it

I don't see any pressing reason to use 4.01 strict. Even XHTML 1.0
transitional is rendered in "standards mode" in every browsers. And
the overhead by ignoring the slash in empty elements got to be
marginale. XHTML 1.0 suites me as well as HTML 4.01.

If you want to convert a pdf document to svg and serve it inside you
layout, and then give a link to that document as an alternative to
browsers that don't support xhtml, why not. Well, it might not be
pressing reason, but it would make your work more accesible.

Quoted text here. Click to load it

That sounds more like a FUD than anything else. Are you talking about
xhtml 2.0 or x/html 5? I got a different result:

Re: Preferred Document Type

Quoted text here. Click to load it

So burn the book and get a better one.  I'd suggest "Head First HTML
with CSS & XHTML", because it's a good book generally and also it
takes a pretty sound line on this question.  I'd also be interested to
know which book it is.

That doctype is _WRONG_. It's bad practice in two separate aspects
(XHTML vs HTML & Transitional vs Strict). Now either of these can
easily be justified in some narrow circumstances, but tutorials for
beginners aren't appropriate for either. Justifying both together is
pretty obscure too.

Quoted text here. Click to load it

If you aren't already au fait with XML syntax, and also with the
complexities of XML in a HTML world, then avoid XHTML in favour of

XHTML _ought_ to be what we're all happily using by now, but the world
(IE being the main culprit) hasn't got there yet and it's still
premature to act as if it has.

Site Timeline