PDA

View Full Version : DTD HTML VS DTD XHTML in scripts



stjohnsnightout
10-09-2010, 07:14 PM
1) Script Title: Omni SLide Menu

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm

3) Describe problem: I use a website development program called webplus and when it publishes html it uses DTD HTML 4.01 Transitional..

The above script will work fine with my website in firefox, but when i view it in explorer it won't. If I change the DTD HTML 4.01 TO DTD XHTML 1.0 like it is in the DEMO.HTM file that comes witht the script, it works perfectly, and so does my website "appear to" . my question is whether this is a good idea?

From my understanding xhtml 1.0 is equivelent to html 4.01. Is This correct?

Some insight would be greatly appreciated..

Bob

jscheuer1
10-09-2010, 08:00 PM
There's a difference between the DTD and the DOCTYPE. The former is a body of rules for the latter. The http://www.w3.org/ website maintains these rules.

With HTML DOCTYPE's less than 5 one must specify the URL of the DTD on the w3.org site, example:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Otherwise IE is in what's known as quirks mode. The menu's generated markup and script code (and many other scripts and markups) do not work well in quirks mode in IE.

All XHTML DOCTYPE's have a URL for the DTD, so if you have a valid XHTML DOCTYPE, you are in standards mode.

Alternatively you may use the very simple HTML 5 DOCTYPE:


<!DOCTYPE html>

which triggers standards mode without a DTD URL in the DOCTYPE.

There is some debate over which is best. Generally though, if you are not serving a true xml page (which if you were, would not work in IE anyway), you should use an HTML DOCTYPE.

traq
10-10-2010, 04:32 AM
<!DOCTYPE html> is simplest. The only thing you really need a doctype to do is trigger standards-compliance mode, anyway.