Log in

View Full Version : What good is a DOC TYPE?



Freeman
11-14-2006, 10:03 PM
What good is a DOC TYPE? It works even if it doesn't have one of these and there isn't really much of a difference for the purpose for them, as far as I have found. Is there a place that talks about the need for a doc type in html? Thanks for the help, JF

TheJoshMan
11-14-2006, 10:41 PM
This is one of the most commonly used DOC Types...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

And here is a link to a page talking about DOC Types...

WDG DOC Type Validator (http://www.htmlhelp.com/tools/validator/doctype.html)

Twey
11-14-2006, 11:12 PM
A DOCTYPE defines the version of HTML that's being used in the document. As such, it is vital in a correctly-formed HTML document. Most browsers will attempt to ignore that and carry on (rendering in Quirks mode), but this is nefariously unreliable (since it deliberately emulates bugs) and inconsistent amongst browsers. Besides, do you really want your page to have to be error-corrected by the browser before being parsed? :p

mwinter
11-15-2006, 02:19 AM
What good is a DOC TYPE?

Read Activating the Right Layout Mode Using the Doctype Declaration (http://hsivonen.iki.fi/doctype/), by Henri Sivonen.



This is one of the most commonly used DOC Types...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Perhaps, though from a practical point of view, it might as well not be there at all. Not because document type declarations should be omitted - they shouldn't - but because a Transitional document type, without the system identifier (the URI), will cause many modern browsers to go into "Quirks" mode.

Either use a Strict document type, or include the system identifier. Preferably do both for any new documents. Also, HTML 4.01 is the current version of HTML; 4.0 was superseded a long time ago.

Mike

BLiZZaRD
11-22-2006, 08:34 AM
Should a website use the same DOC type throughout or is it acceptable for different pages to have different DOC's?

codeexploiter
11-22-2006, 08:41 AM
A good article (http://www.htmlhelp.com/tools/validator/doctype.html) covering this point

BLiZZaRD
11-22-2006, 09:21 AM
Thanks. It explains the different DOC types well, but still doesn't say if it is okay to switch types within a site or not.. :confused:

codeexploiter
11-22-2006, 09:40 AM
I think the main difference of the DOC types comes whenever you validate the page.

The validation is based on the DOC type of your page.

I don't think if we don't consider validation of (X)HTML then there won't be any practical problems with using different DOC types in different pages.

BLiZZaRD
11-22-2006, 09:51 AM
Thanks for the advice!

I try to stay with trans 4.01 but you never know... if I use some XHTML it wont validate... not that many of my pages do at this point, but I am working on redoing them all right now and might as well try, LOL

codeexploiter
11-22-2006, 10:03 AM
To maintain consistent DOC Types in a site is the best strategy i think. So that can avoid any sort of confusing problem especially while validating a site, etc...

BLiZZaRD
11-22-2006, 10:19 AM
That was my goal, and so far have been able too (no XHTML yet) but you never know.. and I thought I might ask while I was here :D

Twey
11-22-2006, 05:53 PM
If your site is well-designed, there should be no need to use anything other than the latest Strict HTML DOCTYPE. However, occasionally people use things like frames which aren't supported by Strict DOCTYPEs. These require a special Frameset DOCTYPE (for the actual frameset, which is quite different in shape to a normal HTML document) and a Transitional DOCTYPE for any pages using the target attribute on links or forms, and this is acceptable (the use of different DOCTYPEs for different pages, that is, not the use of frames or Transitional DOCTYPEs, both of which are less than desirable).
I think the main difference of the DOC types comes whenever you validate the page.

The validation is based on the DOC type of your page.

I don't think if we don't consider validation of (X)HTML then there won't be any practical problems with using different DOC types in different pages.You misunderstand the purpose of validation. Validation by itself means nothing. It's an (hardly exhaustive) indicator of how technically well-written one's page is. The validator checks for compliance to the (X)HTML standard one's page has chosen to follow, which in turn should theoretically guarantee the best support on the widest amount of browsers from now until the DOCTYPE used becomes obsolete. Of course, in practice, it doesn't happen quite so perfectly, since browsers all have their little quirks; however, a valid page is still a good thing to have.

BLiZZaRD
11-22-2006, 06:10 PM
Its hard to conform to DOC type standards when things like the <embed> tag aren't "valid" at all. Which, in my opinion is B.S.

If over half the browsers (including the good ones) won't recognize <object> but will recognize <embed> then where does the problem really lie? Do the standards only apply to IE?

If I want to show Flash, for example on all browsers, I either have to have a "non-valid" page, or "hack" my Flash file which, inturn "tricks" the Netscape browsers into parsing the <object> tag. This, IMO is less valid than using the <embed> tag.

Twey
11-22-2006, 06:26 PM
Not so. Read this page (http://joliclic.free.fr/html/object-tag/en/index.php) for some of the ways <object> can be used.

BLiZZaRD
11-22-2006, 06:35 PM
I got that. I was meaning I can't use the <embed> tag...

take a look at my index page: http://cleverwasteoftime.com

and then when validated the only thing wrong with it is the <embed> part. But if I drop the <embed> tag to make my page validate, I loose the ability to show the page in most netscape browsers... ???

Twey
11-22-2006, 06:42 PM
If you read the page, it should give you a method that works in all major modern browsers.

BLiZZaRD
11-22-2006, 07:08 PM
I did. I removed the <embed> tag stuff and am testing my home page out now in as many browsers as I have avaliable to me...

So far so good...

mwinter
11-22-2006, 09:28 PM
Its hard to conform to DOC type standards when things like the <embed> tag aren't "valid" at all. Which, in my opinion is B.S.

If over half the browsers (including the good ones) won't recognize <object> but will recognize <embed> then where does the problem really lie?

With the browsers, of course. What, exactly, makes you think that the object element isn't sufficient? Through its child param elements, it can specify any plug-in parameter possible.

The problem isn't with HTML, it's with browsers that don't implement it to the degree that they should. The object element is capable of specifying data for any embedded content, including images - one of its initially advertised uses. The fact that it isn't always used for such things is due to poor browser support (and in some cases, the illusion of that), not because the element is deficient.




Not so. Read this page for some of the ways <object> can be used.

The conditional comment part seems backwards, though. Surely:



<object type="video/quicktime" data="data/test.mov" width="320" height="240">
<!--[if lte IE 6]>
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="240">
<param name="src" value="data/test.mov">
<![endif]-->
<param name="controller" value="true" >
<param name="autoplay" value="false">
alt : <a href="data/test.mov">test.mov</a>
<!--[if lte IE 6]>
</object>
<![endif]-->
</object>

would be better? It's shorter, more logical (at least to me), doesn't require markup parsing hacks, and keeps alternative content in one place.

Mike

BLiZZaRD
11-23-2006, 09:03 AM
My main problem was emplimenting the JS files along with the <object> tags, to eliminate the IE activeX click thing.

I have this in mine, it validates, and seems to work in all browsers except Lynx:



<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="language" align="middle" >
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="language.swf" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
</object>

</noscript>
<script language="JavaScript" type="text/javascript" >
<!--
AC_RunFlContentX ("movie", "language", "quality", "high", "src", "language", "width", "550px", "height", "400px" );
//-->
</script>


If it aint broke why fix it type of thing now I guess huh?

GypsyOwl
12-21-2006, 01:00 PM
Great Discussion about Things I have wanted to know more about! :)


Read Activating the Right Layout Mode Using the Doctype Declaration (http://hsivonen.iki.fi/doctype/), by Henri Sivonen.

but because a Transitional document type, without the system identifier (the URI), will cause many modern browsers to go into "Quirks" mode.

Either use a Strict document type, or include the system identifier. Preferably do both for any new documents.
Mike



I have a couple of questions.
First:
When I am using, for example, this kind of doc type with URL:

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

Will I change the URL for each page of the website OR just use the root default URL for all pages?

(as I wrote the question, I think I know the answer, but, I don't want to assume incorrectly)

Another question: May be a different topic :confused:

Situation; A domain is purchased from one vendor and then hosted on another site (currently a sub-domain) there fore, the original vendor location has been given forwarding / masking instructions.
Problem;
The source code isn't showing up (seems to be generated by the domain vendor) and the pages are not viewing properly in all browsers.(note bottom of each page has odd extra type or code showing in IE) additionally, the address bar is mixing up the file names. (example site.html is showing up as contact.html )

Solution ? I am thinking that the solution will involve code changes and moving the site out of a sub-domain. One hosting service does allow multiple domains which brings about many more questions too numerous to post in one topic.

Still Learning- :)

GypsyOwl
12-21-2006, 01:02 PM
Great Discussion about Things I have wanted to know more about! :)


Read Activating the Right Layout Mode Using the Doctype Declaration (http://hsivonen.iki.fi/doctype/), by Henri Sivonen.

but because a Transitional document type, without the system identifier (the URI), will cause many modern browsers to go into "Quirks" mode.

Either use a Strict document type, or include the system identifier. Preferably do both for any new documents.
Mike



I have a couple of questions.
First:
When I am using, for example, this kind of doc type with URL:

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

Will I change the URL for each page of the website OR just use the root default URL for all pages?

(as I wrote the question, I think I know the answer, but, I don't want to assume incorrectly)

Another question: May be a different topic :confused:

>>>Situation; A domain is purchased from one vendor and then hosted on another site (currently a sub-domain) there fore, the original vendor location has been given forwarding / masking instructions.

>>>Problem;
The source code isn't showing up (seems to be generated by the domain vendor) and the pages are not viewing properly in all browsers.(note bottom of each page has odd extra type or code showing in IE) additionally, the address bar is mixing up the file names. (example site.html is showing up as contact.html )

this may be helpful http://www.lapidarybylhianon.com (client's business site that is scheduled to launch in February)

>>>Solution ? I am thinking that the solution will involve code changes and moving the site out of a sub-domain. One hosting service does allow multiple domains which brings about many more questions too numerous to post in one topic.

Still Learning- :) The discussion and the links to tutorials are very helpful, Thanks

mwinter
12-22-2006, 04:53 PM
When I am using, for example, this kind of doc type with URL:

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

Will I change the URL for each page of the website OR just use the root default URL for all pages?

I don't quite follow. Are you asking about changing the URL in the declaration itself? If so, no, that never changes - it can, but doesn't in HTML.



>>>Situation; A domain is purchased from one vendor and then hosted on another site (currently a sub-domain)

Based on the URI provided, it seems that the site is hosted in a subdirectory, not a subdomain. The latter would produce URIs like http://lapidary.gypsyowl.org/contact.html, not http://www.gypsyowl.org/lapidarybylhianon/contact.html.



there fore, the original vendor location has been given forwarding / masking instructions.

"Cloaking" is achieved by framing the target document. This is best avoided, not least because it adversely affects the way search engines index documents. Arrange with your host to have site hosted such that the domain can refer to it directly, rather than just redirect.



The source code isn't showing up (seems to be generated by the domain vendor)

Depends how you try to view it. From the main menu, you'll get the frameset. From the context menu, you'll normally get the frame contents.



and the pages are not viewing properly in all browsers.(note bottom of each page has odd extra type or code showing in IE)

That seems to be a problem with the document itself, rather than something caused by the cloak.



additionally, the address bar is mixing up the file names. (example site.html is showing up as contact.html

The URI will remain at whatever was used at entry. That is, if the visitor enters at http://www.lapidarybylhianon.com/contact.html, then that is what will appear as they continue to navigate through the site. This is because navigation occurs within the frame.

Mike

GypsyOwl
12-27-2006, 10:51 AM
Mike,

Thank you for you time in providing this Very helpful and detailed reply.
I will try to clarify my question about using URL in the DOCTYPE heading.


When I am using, for example, this kind of doc type with URL:

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

GO: Will I change the URL for each page of the website OR just use the root default URL for all pages?
MW: I don't quite follow. Are you asking about changing the URL in the declaration itself? If so, no, that never changes - it can, but doesn't in HTML.
I am creating the HTML documents myself and have not used URL before. Your reply suggests that I would use one http address for all the documents included in one site. OR this URL is designated after it is indexed? (which would mean that I do not manually type this in to the document while I am coding it?)

The rest of your reply is understood. I will find my host's directions for adding a domain (so that LBL is no longer a subdirectory and will not require redirect or cloaking). I will also address the other document problems.

GO

mwinter
12-28-2006, 02:16 AM
When I am using, for example, this kind of doc type with URL:

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

Will I change the URL for each page of the website OR just use the root default URL for all pages?

I don't quite follow. Are you asking about changing the URL in the declaration itself? If so, no, that never changes - it can, but doesn't in HTML.

I am creating the HTML documents myself and have not used URL before. Your reply suggests that I would use one http address for all the documents included in one site. OR this URL is designated after it is indexed? (which would mean that I do not manually type this in to the document while I am coding it?)

Perhaps some background will help. It's purely academic as far as HTML is concerned, though it is relevant in other circumstances. Feel free to skip to the conclusion before, or in lieu, of reading what follows.

The document type definition, or DTD, specifies the syntax of a document. It lists the elements permitted in a document, the attributes for those elements, the possible values of those attributes, and the content model of each element. There are multiple definitions, each of which describes a slightly different variant of HTML.

A HTML document begins with a document type declaration, or DOCTYPE. The contents of the declaration identify an appropriate DTD, and an element within it that acts as the root. In HTML, the root is always the html element.

The declaration can contain two identifiers: public and system. The public identifier is a string than can be used along with a catalogue to find local version of the DTD. If the public identifier conforms to a particular pattern, it's known as a formal public identifier, or FPI. The system identifier is a URI that refers to DTD directly, and is useful when the catalogue doesn't contain an entry for the named identifier.

There's another notable feature of document type declarations, but it's not useful in HTML - you may see it in XML documents.

In HTML, a document type declaration should include all of the components described above:



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

Here, "html" is the root element label, "-//W3C//DTD HTML 4.01//EN" is the FPI, and "http://www.w3.org/TR/html4/strict.dtd" is the system identifier.


It's clear that the public and system identifiers are linked: one is somewhat like the other, albeit in a different form. The system identifier only needs to change if the public identifier changes and vice versa, and the two must always remain in synch - using either the public or system identifier should lead to the same DTD. Whilst the system identifier doesn't have to refer to the W3C website, there's no point in referring elsewhere, from either a practical or purely theoretical point of view.

Any newly-written document should use the Strict document type (see two paragraphs ago) as there's usually little use for the deprecated features of the other variants.

To conclude: use "http://www.w3.org/TR/html4/strict.dtd" with "-//W3C//DTD HTML 4.01//EN"; "http://www.w3.org/TR/html4/loose.dtd" with "-//W3C//DTD HTML 4.01 Transitional//EN"; and "http://www.w3.org/TR/html4/frameset.dtd" with "-//W3C//DTD HTML 4.01 Frameset//EN".

Mike

GypsyOwl
12-28-2006, 08:09 PM
Perhaps some background will help. It's purely academic as far as HTML is concerned, though it is relevant in other circumstances. Feel free to skip to the conclusion before, or in lieu, of reading what follows.

The academics are highly relevant! Again, I Thank You for your very helpful reply.


Any newly-written document should use the Strict document type (see two paragraphs ago) as there's usually little use for the deprecated features of the other variants.

Understood. :)

Kindest Regards,
GO