PDA

View Full Version : Which Dtd (doctype) to use on page?


mattover-matter
04-15-2003, 08:15 PM
How do I know which doctype to use?

pardicity3
04-15-2003, 09:21 PM
Depends exactly what you are coding in, HTML or XHTML. Once you know that then it is a process of choosing which type of doctype, transitional, strict, or frameset.

frameset- This one is obvious, if you are using frames, use this.

transitional- I am not sure if W3 meant this or not, but I usually think of transitional being used if you are transistioning between two languages (i.e. HTML and XHTML). It's less strict but still gets you going in the right direction.

strict- It's just that, strict. Everything has to be exactly according to w3 standards. This is the most standards compliant way of doing things and, as I see it, the only way coding should be done (unless of course you have frames:)).

Hope that helps. I know http://www.w3schools.com has some info on DTD's too if you need more explanation.

<edit>
I also found some good info by searching this forum for Document Type Declaration. Rememer, always search first!!
</edit>

cg9com
04-17-2003, 01:17 AM
The XHTML transitinal DTD, is based on the HTML4.0 transitional DTD, this will support most depricated elements in order to compinsate for older browsers.

Of course the best way to be sure you are using your DTD correctly is to validate it using the W3C markup validator (http://validator.w3.org)

pardicity3
04-18-2003, 12:09 AM
Well since I got scared :( and realised that a topic I posted in is now sticky, I decided to write a little more!

Actually, I just noticed that there are no links to the actual DTD's anywhere. Here is my rundown:

XHTML DTD's (http://www.w3schools.com/xhtml/xhtml_dtd.asp)
HTML 4.0 DTD's (http://www.w3schools.com/html/html_whyusehtml4.asp)

cg9com
04-22-2003, 11:09 PM
And lets not forget the DTD to the module based XHTML (1.1)
Modularization takes markup and turns it into 'subsets' or abstract modules
For example, core modules would be:
Structural elements, Text containers, Hyperlinking, List oriented elements.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

http://www.w3.org/TR/xhtml11

<edit>
And a few side notes:
the DTD will be placed ABOVE your html element <html>.
A DTD is NOT a regular element OR a comment tag,
it's important its not treated like either.
Also note, its important that DOCTYPE is in caps.
</edit>

Java Nuts
05-22-2003, 09:16 PM
hey, (adding a question here;) ) does it matter if you use a DOC TYPE? I have some sites without a DOC TYPE tag. So do you have to have one or is it just..there? lol
and- whats the purpose in them?

thanks - you guys rock:thumbsup:

Saj
05-22-2003, 09:19 PM
Well, the browser will interpret the markup reardless of a Doctype. The Doctype is used to tell the browser what language is used, and where the base Document Type Declaration (W3's DTD file) is located. However, if you don't use valid code, then adding the Doctype is useless, as your browser uses its own DTD to translate the tags.

cg9com
05-24-2003, 06:02 AM
Originally posted by Saj
The Doctype is used to tell the browser what language is used, and where the base Document Type Declaration (W3's DTD file) is located.
This information is called the Document Type Definition

Also, when adhering to a strict XHTML DTD, there are a few important rules, such as including an XML namespace, etc.

For more information on the XHTML DTD jargon, refer to this related thread in the XML catagory, as it covers that particular side of the DOCTYPE:
http://www.codingforums.com/showthread.php?&threadid=17764

giz
05-26-2003, 10:43 PM
List of Valid DOCTYPE statements:

http://www.w3.org/QA/2002/04/valid-dtd-list.html


Up to date: published less than 2 months ago.

giz
05-26-2003, 10:46 PM
pardicity3: Your search ID in the search in your post above has expired.

skinme!
08-08-2003, 12:38 AM
Originally posted by pardicity3
Actually, I just noticed that there are no links to the actual DTD's anywhere.
What do you mean? The actual .dtd files? Then the link's in the Document Type Definition ;)

http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

http://www.w3.org/TR/html4/frameset.dtd
http://www.w3.org/TR/html4/strict.dtd
http://www.w3.org/TR/html4/loose.dtd

http://www.w3.org/TR/REC-html40/frameset.dtd
http://www.w3.org/TR/REC-html40/strict.dtd
http://www.w3.org/TR/REC-html40/loose.dtd

cjwsb
11-06-2003, 02:52 AM
Use strict...

liorean
11-06-2003, 03:07 PM
Originally posted by cjwsb
Use strict...
There are multiple reasons for why you would prefer something other than strict...

hurricane
11-10-2003, 12:20 PM
You may find this useful: http://www.alistapart.com/articles/doctype/

liorean
12-18-2003, 02:44 AM
An old thing I compiled some time ago as a response to a question on XHTML-L, that might be useful to you when you want to know whether XHTML1.0 Strict or Transitional is the DOCTYPE for you:
<http://liorean.web-graphics.com/xhtml/comparison.loose-strict.html>

Another a bit more compact resource on the same thing can be found at:
<http://www.zvon.org/xxl/xhtmlReference/Output/comparison.html>

And finally a shorter table that only takes elements and other markup commands into consideration, but doesn't go into depth about attributes:
<http://www.w3schools.com/xhtml/xhtml_reference.asp>

hrp2171
12-31-2003, 08:47 PM
Here is a link to a web site I found to be very useful too:

http://www.uninetnews.com

I finally got off my lazy behind and created an XHTML template with the DOCTYPE, the xml stuff at the beginning of the file and a link to an external stylesheet. For now I'm using the transitional dtd. I also added the link and image to the w3's online validator. I can't believe how much web developing standards have change. Very cool stuff!

spufi
01-15-2004, 03:54 PM
Originally posted by Java Nuts
hey, (adding a question here;) ) does it matter if you use a DOC TYPE? I have some sites without a DOC TYPE tag. So do you have to have one or is it just..there? lol
and- whats the purpose in them?

thanks - you guys rock:thumbsup:

Standards mode vs. Quirks mode.

This is what standards mode is. With a full doctype, the designer let's the browser know that they followed a certain set of rules defined by w3c and the browser then tries to interpret the code as best as it can for those set of rules.

This however is quirks mode. Even with w3c valid code(minus Doctype), the browser doesn't know what set of rules to follow so it decides for the user which set of rules to follow. This may be based on what the most current version of the browser can handle, but sometimes, the browser will try to read your code based on a prior version of the browser, incase you used "outdated" coding. This now means that certain things like CSS don't perform like they should even though you have code that should work in the actual version of the browser. As an example, I believe a later version of Netscape would throw the browser into quirks mode if no Doctype was used. What previous version of the browser did it then use? Netscape 4.7. Yikes.

When in doubt, use a full Doctype and valid your code. Also note that valid markup will be by default the most cross browser friendly way to code.

me'
01-16-2004, 05:32 PM
When in doubt, use a full Doctype and valid your code. Also note that valid markup will be by default the most cross browser friendly way to code.When in doubt? Absolutely always include a doctype, much preferably strict, use transitional only if you absolutely *have* to do something that isn't allowed by the strict one.

LinuxGold
02-06-2004, 05:06 PM
Hmm.. too much technical terms and overwhelms me. What can doctype benefit the browsers? I'm trying to grasp the idea of that doctype interpretation.


Examples would better suffice as visual aid.

Tails
02-06-2004, 07:22 PM
The Doctype is nothing new I think. The browser sees it and follows the rules. I doubt it has to download a copy and learn it each time you load a page though (although if old browsers that are new to the new standards can, self-adapt, that's great).

There different levels of coding, such as HTML 4 transitional, to XHTML Strict. Some changes took place between HTML and XHTML. These changes (aside from the strict syntax) includes some new defaults. One of them is that in a table with 0 cellspacing and cellpadding and images in each cell will still keep some space between the top and bottom of an image (IE doesn't fully implement these changes but Mozilla does. Use display:block for compatibility with all doctypes).

When you use a Doctype, you will know exactly how the page will render on another viewer's browser. However without the Doctype, the page will be rendered in Quirks Mode and the browser will assume different things and may ruin the look of your page. Qurks Mode is not a predictable thing; each browser can make their own wild guesses on what to do, while with a Doctype, the rules are there and will ensure that your page will not be misinterpreted.

Afrow UK
03-12-2004, 09:44 PM
I'm having to use XHTML Transitional, because, well strict does not allow standard forms which I need on my site! I heard something about XHTML Forms - is this something different and unique?

-Stu

Tails
03-12-2004, 09:57 PM
Originally posted by Afrow UK
I'm having to use XHTML Transitional, because, well strict does not allow standard forms which I need on my site! I heard something about XHTML Forms - is this something different and unique?

-Stu

Forms in XHTML change in the following ways:

the form tag must have an action attribute (can be blank)
input and textarea tags must go inside a form tag, always


That's all I can remember, it's nothing really special when changing to XHTML.

dannyhayes
03-29-2005, 04:01 PM
Hi,

The best website to read up on xhtml is definately w3school's xhtml section.

http://www.w3schools.com/xhtml/xhtml_reference.asp

JamieR
03-29-2005, 04:10 PM
You are supposed to serve your XHTML as application/xhtml+xml but IE doesn't support XML:mad:

Kurashu
03-29-2005, 06:38 PM
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml;charset=UTF-8");
}
else {
header("Content-type: text/html;charset=UTF-8");
}


Funny story, IE yelled at me for having an XML error on a page with that code on it, as did Moz and its little brother and Opera....

Maybe IE isn't tell ing us something?

xD Nah it probably saw the others and something along these lines happened:
IE: "Uhhhh yeah, you got an error >_> <_< Mozilla what was the error again?"
Mozilla: "GET YOUR OWN ERROR!"
Firefox & Opera: "OOOOOH! Burn."

rpgfan3233
04-02-2005, 08:15 PM
The best website to read up on xhtml is definately w3school's xhtml section.

http://www.w3schools.com/xhtml/xhtml_reference.asp

If you are new to XHTML. Once you are more experienced, I recommend the actual documents:
XHTML 1.0 Specification (http://www.w3.org/TR/xhtml1/)
XHTML 1.1 Specification (http://www.w3.org/TR/xhtml11/)
XHTML 2.0 (WD) (http://www.w3.org/TR/xhtml2/)

Learn XHTML 1.1 then forget about some of it when XHTML2 is released. That's when you should learn XHTML2.

<Eddie />
04-05-2005, 06:02 PM
A commercial website should be written in HTML as it has wider compatibility than XHTML. Writing XHTML is a good excuse to learn a new skill and tidy up your act when developing but has no real benefit when not being consumed by XML services.

Strict is my preferred doctype but transitional is just as valid a standard as strict and funtionality shouldn't be sacrificed for doctype.

Simonp
06-08-2005, 01:50 AM
Hey guys, from what I know, the doctype is there to try to get everyone to adear to some sensible standards for web design and coding. It's there to benefit users, not coders. It fulfils a number of key tasks.

1. It switches a compliant browser (one that understands the declaration) into standards mode from quirks mode, and it will try to strictly render the page according to the doctype declared. Beware if your code is not valid (test it on the w3c site) as the browser will probably lash it up.

2. The different doctypes should be carefully chosen depending on what you are coding and the language of choice - frameset, transitional etc or HTML , XHTML etc.

3. The main difference between transitional and strict, is that strict will not allow tables to be used for layout - data only! (use css instead and completely seperate presentation from mark up)

4. The main benefit is to try to get everyone doing the same thing in the same the way, and to get browser makers to make browsers handle everything in the same way - yippy!!!

5. All user agents (browsers including assistive and emerging technologies) will try to read the doctype and render it accordingly.

6. According to UK law (section 508 in US) you are now legally obliged to make web sites accessible, and according to checkpoint 5.2 (I think) of the W3C/WAI guidlelines you cannot be accessible to priority level 2 if you do not write compliant code.

I hope this helps a little. :thumbsup:

Jemmie
07-06-2005, 01:35 PM
3. The main difference between transitional and strict, is that strict will not allow tables to be used for layout - data only!
As far as I'm aware the validator cannot tell the difference between a data table and a layout table so saying "it will not allow tables" is theoretically incorrect. I think the words "you should not use tables" is probably more appropriate?

I could be wrong on this of course..

Bill Posters
07-06-2005, 02:11 PM
Here is a link to a web site I found to be very useful too:

http://www.uninetnews.com

I finally got off my lazy behind and created an XHTML template with the DOCTYPE, the xml stuff at the beginning of the file…
(Sorry if that has been mentioned already.)

Unless you're serving the page as application/xhtml+xml the xml prolog is of no use. The only real impact it has on a page it to trip IE6/Win into dealing with an otherwise valid page in quirks mode.
Point being, unless you're serving your xhtml markup as application/xhtml+xml, then ditch the xml prologue.

-

I heard something about XHTML Forms - is this something different and unique?
I guess you're thinking of XForms (http://www.w3.org/MarkUp/Forms/), which are a 'next generation' thing which, afaik, are still at the formative stage and not really ready for showtime yet.

-

I could be wrong on this of course..
Nope, you're quite correct.

-

Fwiw, I use XHTML 1.0 Strict by default now, which I conditionally serve as application/xhtml+xml or text/html depending on the capabilities of the UA. I do this, at this time, aware that there are few real benefits, but do so mostly as an exercise in keeping abreast of mdoern standards as someone who is keen to produce progressive, well-formed and portable ouput. (The syntax of XHTML is marginally more robust than the HTML syntax.)
There's nothing that's been deprecated between Transitional and Strict that I can't live without, or can't functionally replace by more progressive methods.


I've yet to hear a convincing argument (i.e. one that offers genuine benefits, rather than one that simply satisfies the 'perceived need' for deprecated elements/attributes/methods) in favour of using anything other than a Strict DTD, whether it's HTML 4.01 or XHTML 1.0 (or XHTML 1.1).

Jemmie
07-07-2005, 01:48 PM
I do this, at this time, aware that there are few real benefits, but do so mostly as an exercise in keeping abreast of mdoern standards as someone who is keen to produce progressive, well-formed and portable ouput.
Which is exactly why I use the XHTML Strict doctype too.

Kurashu
07-07-2005, 07:19 PM
I use XHTML 1.0 Strict most often; however, sometimes, when I'm feeling giddy, I'll use 1.1 instead.

Bill Posters
07-08-2005, 09:30 AM
I use XHTML 1.0 Strict most often; however, sometimes, when I'm feeling giddy, I'll use 1.1 instead.
Are serving that as application/xhtml+xml and using content-negotiation to reduce that to XHTML 1.0 (as text/html) for IE6?
(The spec doesn't permit XHTML 1.1 markup to be served as text/html whereas is does with XHTML 1.0 markup.)

(W3.org) What mime-type should XHTML be served with? (http://www.w3.org/2003/01/xhtml-mimetype/)

gsnedders
07-08-2005, 12:57 PM
Are serving that as application/xhtml+xml and using content-negotiation to reduce that to XHTML 1.0 (as text/html) for IE6?
(The spec doesn't permit XHTML 1.1 markup to be served as text/html whereas is does with XHTML 1.0 markup.)

(W3.org) What mime-type should XHTML be served with? (http://www.w3.org/2003/01/xhtml-mimetype/)
It doesn't not permit it, it just shouldn't be done. Even XHTML 1.0 Strict as text/html is bad IMO, as you lose all the advantages of XHTML.

Personally, I normally use HTML 4.01 Strict now, for full browser compatibility.

Bill Posters
07-08-2005, 01:06 PM
It doesn't not permit it, it just shouldn't be done. Even XHTML 1.0 Strict as text/html is bad IMO, as you lose all the advantages of XHTML.

Personally, I normally use HTML 4.01 Strict now, for full browser compatibility.

I was speaking (writing) in the prescribed sense, i.e. that it's not a prescribed option in the way that text/html is permissable for XHTML 1.0.
It's not permissable in the sense that the target attribute isn't permissable for XHTML Strict. Browsers (and quite probably, validators) are still likely to accept it, but it's not an endorsed application of the spec.
Anyway, that's what I meant.

capneb
10-05-2005, 04:13 AM
Not just because it's super compliant. But because if you leave out the encoding meta-tag, and are using a transitional DTD, some browsers will see the ...sitional//EN" and interpret the lowercase ell followed by a slash as a ł from the Tlingit, Polish, etc languages. Then, if no encoding is specified, the page is rendered as if you didn't include any DTD at all.

oldcrazylegs
10-05-2005, 07:35 PM
Can a DTD be changed to allow you to use style sheets in the <title> tag?

Bill Posters
10-05-2005, 08:24 PM
Can a DTD be changed to allow you to use style sheets in the <title> tag?

Nope. Only elements that appear within the viewport (the viewing area) fall within the scope of CSS.

gsnedders
10-07-2005, 02:56 PM
Well, the DTD can be changed to allow the style attribute of the title element. It'd be useless though.

codeteacher
11-29-2005, 03:13 PM
Personally, I never use Strict. It makes thing overcomplicated..

Bill Posters
11-29-2005, 03:26 PM
Personally, I never use Strict. It makes thing overcomplicated..
Personally, I find it helps keep things more simple, straight-forward and focussed.
Transitional introduces too many variables that I'd rather do without.

gsnedders
11-29-2005, 05:39 PM
Personally, I never use Strict. It makes thing overcomplicated..

Transitional doctypes are exactly what the name implies: a doctype for a phase of transition, not meant to be used permanently.

It's up to you. I'd never use Transitional doctypes pernamently for that very reason.

ampulator00
04-07-2006, 11:26 PM
I use only XHTML !.1 now. It was tough at first, but now it makes my web pages very easy to manage.

Bill Posters
04-08-2006, 03:49 PM
I use only XHTML 1.1 now. It was tough at first, but now it makes my web pages very easy to manage.

Curious to know... :)
Are serving that as application/xhtml+xml and using content-negotiation to reduce that to XHTML 1.0 (as text/html) for IE6?
(The spec doesn't permit XHTML 1.1 markup to be served as text/html whereas is does with XHTML 1.0 markup.)

(W3.org) What mime-type should XHTML be served with? (http://www.w3.org/2003/01/xhtml-mimetype/)

zealotgi
07-24-2006, 08:16 PM
I use only XHTML !.1 now. It was tough at first, but now it makes my web pages very easy to manage.

Yeah, it is a lot easier than XHTML 1.0

felgall
07-24-2006, 08:50 PM
Use a strict doctype unless you have a specific reason why it is inappropriate for a given page.

Always use a doctype as pages without doctypes display completely differently in different browsers while properly coded pages with doctypes can look very similar in different browsers. Pages without doctypes were usually designed for Internet Explorer and look like garbage on other browsers.

quibs
09-23-2006, 01:10 PM
AS IM LOOKING INTO A PROBLEM WITH MY PAGE I CAME ACROSS THESE THEY ARE THE CORRECT DOCTYPES TO USE.
DOCTYPES THAT WORK
So what DOCTYPEs should we use? Glad you asked. The following complete DOCTYPEs are the ones we need:

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


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


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">XHTML 1.0 Strict, Transitional, Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">XHTML 1.1 DTD

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Michael B
10-04-2006, 07:14 AM
No one has said this I think so I will.

If you do not have a doc type, your page gets treated as something like HTML 3.2 plus random HTML junk. This also happens if you serve XHTML as text/html because your telling the browser to treat the page as html but given a non html doc type.

I have just lost all my bookmarks so I can't give a link to back that up. :(

nolvorite
12-15-2006, 05:01 AM
I will tell you NEVER to use XHTML DTD. If you use XHTML, there will be more problems surely will occur around.

Bill Posters
12-15-2006, 07:25 AM
I will tell you NEVER to use XHTML DTD. If you use XHTML, there will be more problems surely will occur around.

And I will tell you that you are talking nonsense.
Don't judge others by your own inabilities.

ahallicks
12-15-2006, 05:05 PM
XHTML is basically HTML, but slightly more compliant with web browsers. Yes it is more difficult to validate an XHTML doctyped (?) page but that is because it is simply better practise to code things well... and getting it right is not always easy, but it is possible and XHTML is simply a version of HTML that W3Schools sees as the most compliant language.

There is nothing wrong with it, and I use both HTML and XHTML... but my personal preference is to get the elation of knowing I've created a strictly valid XHTML document with a valid CSS stylesheet.

croatiankid
12-15-2006, 05:34 PM
I only use XHTML when I really need it, like for web applications, and working with CMSs

codingmasta
12-22-2006, 08:50 PM
You should NEVER use XHTML dtd. They need appropriate spaces and takes you a longer time. Hover, you can use either strict or transitional

whizard
12-22-2006, 09:05 PM
You should NEVER use XHTML dtd.

That is incorrect. It takes a little more effort, but the code you end up with when you write it to meet XHTML standards is lighter, faster, and leaner (not to mention easier to read.

Don't be put off by a little work! Sometimes it's worth it..!

Dan

codingmasta
12-24-2006, 06:31 PM
I hate xhtml

Bill Posters
12-24-2006, 08:53 PM
You should NEVER use XHTML dtd. They need appropriate spaces and takes you a longer time. Hover, you can use either strict or transitional
It might take you longer, but it doesn't take me any longer.
If you're familiar with it, then coding xhtml-compliant markup takes no longer than html 4.01.

Additionally, you should ideally aim to use a Strict doctype as Transitional will not always trigger full compliant mode in some browsers (e.g. 'almost standards' mode), whilst a Strict doctype will. A Strict doctype will give you the best shot you have of getting consistant, x-browser results from your code.

Suggested reading…
http://24ways.org/2005/transitional-vs-strict-markup

I hate xhtml
I suspect you hate it for reasons which are more to do with you than xhtml.

wslaat
01-27-2007, 12:59 AM
I only use XHTML when I really need it, like for web applications, and working with CMSs

felgall
01-27-2007, 08:57 AM
Even if you write using HTML you should still include all of the tags and attributes that you would need if it were XHTML (apart from the extra slash for self closing tags). Leaving out tags or quotes around attributes is extremely poop coding practice and will eventually result in your wasting a huge amount of time trying to figure out why it isn't working correctly.

croatiankid
02-17-2007, 06:01 PM
Even if you write using HTML you should still include all of the tags and attributes that you would need if it were XHTML (apart from the extra slash for self closing tags). Leaving out tags or quotes around attributes is extremely poop coding practice and will eventually result in your wasting a huge amount of time trying to figure out why it isn't working correctly.
No it won't, because according to HTML specifications you CAN OMIT some tags (for example HTML and BODY, look here for an example (http://www.croatiankid.com/).

Shoot2Kill
02-22-2007, 12:28 AM
i'm sorry, but for a matter of 5 seconds to write

<html>
..and..
<body>
..etc...

why would you publish a website without it... seems lame to me, and well, just idle...

croatiankid
02-22-2007, 01:16 PM
By the way you can also omit HEAD.
Why?
to remove unnecessary markup.
one might say to clean up the code from unnecessary markup.
to take 6 lines that don't have to be in your code, out.
not to mention, to comply with w3c (who say that you can omit them).

Shoot2Kill
02-22-2007, 06:57 PM
Just because you CAN doesn't necessarily mean you SHOULD...

I'm sure if it came to a vote on a site like this, then USE TAGS would win, hands down...

croatiankid
02-22-2007, 09:07 PM
that's because most people don't know that you don't have to use them. why clutter the markup with unnecessary markup?

rmedek
02-22-2007, 09:32 PM
A nice read on this developing discussion: http://www.webreference.com/html/tutorial3/1.html

felgall
02-22-2007, 11:49 PM
why clutter the markup with unnecessary markup?

You shouldn't clutter the page with unnecessary markup. Just because something is optional in the W3C standards doesn't mean that it is unnecessary though. Some optional tags/attributes are actually optional and are unnecessary except where you need to use them (eg. the id, class, and title attributes that could be put into every tag in the body of your page). Other tags that the standard lists as optional are only listed as optional because a lot of people (used to) leave them out and so they are defined that way so as to define where browsers should add the missing tags. The web page actually needs these tags but the browser can add them if you leave them out although not necessarily where you might have expected if you have made coding errors in your markup. Including the optional but necessary tags in your code means that you will more easily detect markup errors as well as saving the browser the trouble of having to add them. Such optional but necessary tags include <head> </p> and <tbody>.

gamesinwild
02-23-2007, 07:56 AM
it's good to use xhtml transitional, since it's xhtml and doesn't have much difficulty.

croatiankid
02-24-2007, 02:17 PM
Without those tags you have valid html that is parsed by every w3c compliant browser and several that aren't (including IE). So why are they not unnecessary?

Bill Posters
02-24-2007, 04:06 PM
it's good to use xhtml transitional, since it's xhtml and doesn't have much difficulty.

Unfortunately, not all browsers treat Transitional doctypes the same; they don't always trigger the same level of standards-compliance as a Strict doctype.
Imho, the only manner of doctype worth considering is Strict (whether that be HTML 4.01 or XHTML 1.0) precisely because of that extra strictness in the behaviour of UAs.

Additionally, imho, there's nothing important or essential in Transitional which isn't also available in Strict.

- - -

On the issue of 'implied/optional' tags…

I'm all for including them for reasons outlined in the article to which rmedek linked - namely the facility to add attributes.

I often use add dynamic id attributes to the body element as a hook for page-specific nav menu customisation. Similarly, I've been known to add an id for the html element as a hook for others to add their own site-specific, client-side adaptations.

I haven't yet found the need to add attributes to the head element, but given that the tags appear in my typical stationery templates, I see no particular benefit to go out of my way to start removing them either from those projects which I code from scratch myself or those projects where I'm simply dealing with code written by another.

Of course, my tendency towards XHTML markup makes the point largely moot; XHTML markup requires the actual presence of those elements in the markup in order to be valid.
However, even when using HTML 4.01, I see little, if any, benefit to omitting the implied elements from the markup.
Clarity is always a good thing and anything which aids that, particularly in cases where a site may be checked or maintained by 3rd parties, is also a good thing.

The 'savings' certainly aren't significant and the only real benefit that I can see is that those who use it get to feel a little more smug about their mastery of the markup over those who choose to use them and who recommend that others do likewise. (I have a similar view about those who condescend about serving XHTML 1.0 as text/html bleating on about how we should use HTML 4.01 instead.)

For those using both HTML 4.01 and XHTML markup schemes for different projects, I see no purpose to running two approaches. Imho, it's better to work with one 'habit' which is known to work without issues in both HTML 4.01 and XHTML scenarios.


Bottom line: imho, omitting implied elements has absolutely no convincing or even significant benefits.

Shoot2Kill
02-24-2007, 08:19 PM
ok, im not 100% sure, but i am trying to work it out.

removing these tags makes the file smaller and quicker loading times? (is that what ur saying croatiankid)

but if the browsers have to find where the tags should go, and enter them, this must waste time that the browser can be processing the page, which makes the page load slower..

i am not totaly sure on this like i said, it was just my bit of logic :P

felgall
02-24-2007, 09:31 PM
If you leave out optional tags then when you return to the page years later to make changes you may add something in the wrong place in the page because the tags that tell YOU what is what were left out. The XHTML standards define all necessary tags as mandatory while the HTML standards specify ones that a lot of newbies leave out as optional so that the browsers can still figure out what the page means. Go ahead aond leave them out if you like but you will probably end up wasting days if not months of your time figuring out errors at a later date that would have been easily identifiable if the optional tags had been included.

The W3C standards are those the browsers are supposed to follow. They only make up about half if that of the standards that people writing web pages should follow since there are many things the W3C standards allow you to get away with that will waste lots of your time if you don't do it properly, particularly at a later date when your changes don't work.

croatiankid
02-25-2007, 10:21 AM
If you leave out optional tags then when you return to the page years later to make changes you may add something in the wrong place in the page because the tags that tell YOU what is what were left out.
That is the purpose of comments, not optional tags.

Shoot2Kill
02-25-2007, 04:34 PM
so you are gonna make the file size smaller by leaving out

<HTML>
<HEAD>
<BODY>

tags, but you are gonna increase it with loads of unnecessary comments.. :s

felgall
02-25-2007, 06:09 PM
That is the purpose of comments, not optional tags.

So when it comes to commenting where the head of your page starts and finishes which way are you going to do it?

<!-- start of head -->
<!-- end of head -->

OR

<head>
</head>

The second way is shorter, just as obvious, saves the browser from having to work it out AND will make finding errors easier.

In addition the standards you should be following in commenting your code is to use as few comments as necessary by making the code itself as readable as possible. If you use the head tag itself to "comment" where the head of your page is then you KNOW that the tags are in the right place. If you use comments instead then the next time you update the page to add something to the head and put it in the wrong place then your comments are WRONG but the page still works. Comments should explain WHY code is the way it is and not WHAT or HOW. Explaining what and how are the job of the code itself.

phoenixshade
02-25-2007, 08:48 PM
No it won't, because according to HTML specifications you CAN OMIT some tags (for example HTML and BODY, look here for an example (http://www.croatiankid.com/).
Sorry, but that's just nonsense. I use XHTML 1.0 Strict on everything I create. No problems with it. If you use something else, you'll be working with the dominant browser on the internet in quirks mode, throwing your carefully-laid plans into havoc.

But then again, if you're averse to using XHTML, you probably are still positioning everything with <table>s and such. Talk about your unnecessary tags! CSS is so much better for this.

Sman5109
02-25-2007, 08:53 PM
Sorry, but that's just nonsense. I use XHTML 1.0 Strict on everything I create.

Let me ask you a question, if you create something new, why use xhtml 1.0 when you could go up one to xhtml 1.1? 1.0 is outdated.

rmedek
02-25-2007, 10:17 PM
Let me ask you a question, if you create something new, why use xhtml 1.0 when you could go up one to xhtml 1.1?

Because 1.1 needs to be sent as XML and Internet Explorer will choke on it?

Sman5109
02-25-2007, 11:47 PM
Because 1.1 needs to be sent as XML and Internet Explorer will choke on it?

IE6 or 7?

If you are having to downgrade your websites/pages so they work in older browsers I say screw it, make your pages so they work with the newest browsers, like FF2 and IE7. If people don't want to upgrade their browsers then they have to suffer with the consequences. Don't make your pages suffer.

rmedek
02-26-2007, 01:26 AM
If you are having to downgrade your websites/pages so they work in older browsers I say screw it, make your pages so they work with the newest browsers, like FF2 and IE7. If people don't want to upgrade their browsers then they have to suffer with the consequences.

Wow, as long as we're dreaming happy clouds and fluffy puppies, I want a pony.

Like it or not, some people think the whole point of the internet is to have content be accessible to all people, regardless of media device. Also, this whole point of "1.1 is new, 1.0 is old," is baseless and misinformed:

http://annevankesteren.nl/2004/12/xhtml-notes

croatiankid
02-26-2007, 07:31 AM
Sorry, but that's just nonsense. I use XHTML 1.0 Strict on everything I create. No problems with it. If you use something else, you'll be working with the dominant browser on the internet in quirks mode, throwing your carefully-laid plans into havoc.

But then again, if you're averse to using XHTML, you probably are still positioning everything with <table>s and such. Talk about your unnecessary tags! CSS is so much better for this.
No you won't. have a look at this (http://hsivonen.iki.fi/doctype/). And why am I probably still positioning everything with TABLE? Did you even look at the url I gave? CSS is not limited to xhtml...
I keep getting the impression that a lot of people are using xhtml "just because they can", not actually using a benefit of xhtml (being xml and in combination with xml tech such as mathml etc), just like some people are getting the impression that i, or one can omit tags in html "just because we can".

Bill Posters
02-26-2007, 08:27 AM
IE6 or 7?

If you are having to downgrade your websites/pages so they work in older browsers I say screw it, make your pages so they work with the newest browsers, like FF2 and IE7. If people don't want to upgrade their browsers then they have to suffer with the consequences. Don't make your pages suffer.
Just to be clear, neither IE6 or IE7 support XHTML 1.1 when served appropriately as application/xhtml+xml. There were hopes that IE7 would support it, but MS backed away from those plans.

phoenixshade and Sman5109: Your enthusiasm is commendable, but you both need to be getting your head round certain facts first, before wading into discussions such as this. You risk embarrassing yourself and undermining your credibility when you make statements which are so fundamentally flawed and misinformed.

phoenixshade
02-26-2007, 05:16 PM
phoenixshade and Sman5109: Your enthusiasm is commendable, but you both need to be getting your head round certain facts first, before wading into discussions such as this. You risk embarrassing yourself and undermining your credibility when you make statements which are so fundamentally flawed and misinformed.

And you need to read people's posts before you hurl insults. I said that I use XHTML 1.0, not 1.1. That is supported by FF2 and IE7. It can be served as HTML. And it encourages the habit of creating well-formed documents. There's nothing "fundamentally flawed" about this, whether you agree with my decision to use it or not.

Also, if you think someone is so misinformed, rather than insulting his intelligence, you should offer a resource that will help them expand their knowledge. Your statement above is insulting and not in the least bit helpful.

croatiankid: I apologize for making assumptions about your development techniques. My main reason for using XHTML is that a considerable percentage of my clients are in the fields of molecular biology, genetics, and physics, and I regularly need to use mathml.

Bill Posters
02-26-2007, 05:37 PM
And you need to read people's posts before you hurl insults. I said that I use XHTML 1.0, not 1.1. That is supported by FF2 and IE7. It can be served as HTML.
Where do I suggest otherwise?

The portion of my comment which was directed to you, including the comment which you emphasised, was a response to your baseless attempt to infer from a member's use of HTML 4.01 that they probably used tables for layouts.
Fwiw, I use XHTML 1.0 Strict markup myself and recommend its use to others - even if served as text/html (App. C). Whilst I rarely make full use of the XML environment, I use and endorse the use of XHTML 1.0 Strict markup largely, as you point out, as XHTML markup encourages a better appreciation of document structure and Strict-ness supports the ideals of separation (structure, presentation, behaviour, etc…).

My quoted comment about XHTML 1.0, 1.1 and IE7 was directed solely at Sman5109, which is why I chose to quote him/her directly.
I apologise if that wasn't entirely clear.

croatiankid
02-26-2007, 06:32 PM
omg people here keep using more and more stuff like FWIW and leetspeek acronyms i keep having to look up wikipedia lol

rmedek
02-26-2007, 06:43 PM
And with that, I think this thread is exhausted, ¿no?