XHTML or HTML as a convention and best practice

Hey all,

I was browsing this doc on HTML/XHTML/XML

http://webkit.org/blog/?p=68 and it reminded me of something we discussed, which was the doc type in our web pages, and what we chose to do in our blueprints examples, We are not as consistent as we should be with this.

Do we agree with this snippet from this artcle?

"

Best practices

On today's web, the best thing to do is to make your document HTML4 all the way. Full XHTML processing is not an option, so the best choice is to stick consistently with HTML4. Here's the best way to do that:

1. Use an HTML4 doctype declaration <http://webkit.org/blog/?p=68>,

ideally one that will trigger "standards mode" in web browsers.

One example of an HTML4 standards mode doctype is |<!DOCTYPE HTML

PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">|

2. Serve your content with the |text/html| MIME type, or for local

content give it a |.html| or |.htm| suffix. This will lead

browsers, search engines, and other apps to properly process your

content as HTML.

"

I know we had some issues in our code examples like petstore 2.0 with the popup component and catalog page when the http://www.w3.org/TR/html4/loose.dtd DOCTYPE was used in some pages.

Why did we not use Xhtml? What conventions did we choose and why? Those are questions we should address.

Overall, we should choose a convention in blueprints for XHTML or HTML? What do folks think shpould be the convention and best practice?

thx,

Sean

[1630 byte] By [seanbrydona] at [2007-11-26 17:42:39]
# 1
I think the recommendations in the article make sense. So, we should go ahead and implement them.
inder0a at 2007-7-9 0:10:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Specifying the Doctype is absolutely necessary as it will change the way a browser renders content. Content can be rendered by a browser in strict mode or quirks mode. Things like element positions that are returned and the handling of CSS box model differ between these two modes. For more on this see the link at the bottom where you can find out more.

In essence it comes done to this:

When to use Strict Mode:

You can use XHTML in strict mode which would require that all the scripts that modify the browser object model (BOM) or content be well formed. There are a set of web designers out there that insist on pure well formed XHTML but in practice it is difficult to do. If you have complete control over your scripts and content this may be for you.

When using strict mode use the following doctype:

<!DOCTYPE html

PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

When to use Transitional / Loose Mode:

In most cases you are going to want your browser to be a little more lenient when parsing pages but still have some structure to it. This can be achieved by using the Transitional Doctype.

In the past this was commonly used:

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

You really should be using the more current XHTML Doctype which as the same effect.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Using this Doctype you can have a

or an <input ....> tag that are not properly formed and not have your browser chock. If you are going to use any external libraries that might not have pure XHTML or if you have intermixed scripts or use scripts that don't always render pure XHTML then the Transtional Doctype is for you. I personally recommend this Doctype.

There is more detailed description of these modes on quirksmode.org which can be seen here:

http://www.quirksmode.org/css/quirksmode.html

W3C on XHTML Strict and Transitional:

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

gmurray71a at 2007-7-9 0:10:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...