Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > XHTML or HTML 4 ?

Reply
Thread Tools

XHTML or HTML 4 ?

 
 
Marc
Guest
Posts: n/a
 
      01-12-2006
Which doctype should we be writing to now? What are the advantages /
disadvantages? I usually write to XHTML1 Strict, but someone in here
said they don't recommend using XHTML at all... why?

Marc
 
Reply With Quote
 
 
 
 
saz
Guest
Posts: n/a
 
      01-12-2006
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> Which doctype should we be writing to now? What are the advantages /
> disadvantages? I usually write to XHTML1 Strict, but someone in here
> said they don't recommend using XHTML at all... why?
>
> Marc
>


HTML can be read by any browser currently in use, which is not true of
XHTML. I can't find any compelling reason to use XHTML at this time
(okay, start flaming me)
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      01-12-2006
Marc wrote :
> Which doctype should we be writing to now? What are the advantages /
> disadvantages? I usually write to XHTML1 Strict, but someone in here
> said they don't recommend using XHTML at all... why?
>
> Marc


The most important thing is to write with a strict DTD. Strict DTD will
bring all modern browsers (they all do support rendering mode based on
doctype declaration) into web standards compliant rendering mode. In
case of MSIE 6, this is very important to do since MSIE 6 in standards
compliant rendering mode will implement correctly the CSS box model.

Overall, strict DTD disregards elements and attributes used for
presentational/style purposes: your markup code makes better (or more
correct) use of the HTML code in its original intent, in its best
intended purpose. Usage of elements like <font>, <center>, etc. and
attributes like bgcolor, vspace, etc. are formally deprecated and should
be replace by use of CSS.

Reasons why HTML is to be preferred to XHTML are mentionned in 2 well
written documents:

Sending XHTML as text/html Considered Harmful
http://www.hixie.ch/advocacy/xhtml

Say NO to XHTML
http://www.spartanicus.utvinternet.ie/no-xhtml.htm

Gérard
--
remove blah to email me
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      01-12-2006
On Thu, 12 Jan 2006 09:29:25 -0600, saz <(E-Mail Removed)>
wrote:

>HTML can be read by any browser currently in use, which is not true of
>XHTML.


Which browsers can't read Appendix C XHTML ? Given the tag soup that
browsers _must_ support to be vaguely usable on the web, I doubt there
is a single one.

Recommendations:

Don't use XHTML 1.1 or 2.0

If you do use XHTML, use Appendix C.

Use Strict (either one), because it keeps IE's CSS rendering models
under control. IMHO it's better to be slightly invalid (with <a
target="" > etc.) than to lose Strict in favour of valid Transitional.

Coding style depends on more than doctype. <font> will either be there
or it won't, depending on whether you use it. Using Transitional doesn't
make it compulsory!

There's also no reason why a site needs a consistent doctype. If it's
hard to do it on a particular page, change doctype.

XHTML is hard to generate from XSLT - if you're using Appendix C. You
may find HTML easier to keep valid. XHTML-as-XML (as generated by XSLT
with <xslutput mode="xml" > ) is not a good choice for the web - it
certainly will cause problems.

As to which is better, HTML 4.01 vs. XHTML 1.0 / Appendix C, then there
just isn't anything clear to choose between them. If there was, then we
wouldn't need to argue over it.
 
Reply With Quote
 
cwdjrxyz
Guest
Posts: n/a
 
      01-13-2006

Marc wrote:
> Which doctype should we be writing to now? What are the advantages /
> disadvantages? I usually write to XHTML1 Strict, but someone in here
> said they don't recommend using XHTML at all... why?


The most important thing is that you use some valid type of html. Even
old 3.2 would serve for very simple pages and is still understood by
most browsers. However it is quite common for many pages from large
corporations to be written in a html soup ranging from html 3.2 to
xhtml levels. Some such pages likely were started many years ago and
just added to by various people over the years. It is no surprise that
some such pages have problems with some common browsers and often fail
and must be patched at new browser upgrades.

Concerning xhtml 1.1, it can be used if you make the effort to learn it
well. At a minimum, in addition to writing valid html 1.1 code, you
must set up your server to serve the page with the mime type of
application/xhtml+xml associated with the extension .xhtml, or you can
also serve as .xml. If you serve a page written in valid xhtml with the
extension .html on most servers, you are just serving the page as html
and might as well use 4.01 strict. When you serve true xhtml 1.1 with
the proper mime type, you will find that it will be viewed well on the
recent Mozilla family browsers(Firefox, Mozilla, and Netscape) and
Opera. There are a few bugs in some browsers that can be overcome, such
as a CSS body background color one on the Mozilla family browsers.
However, IE6 will not display a true xhtml page served correctly, and
rumor has it that neither will the upcoming IE7. You could write a
special page for IE in html 4.01 strict as well as the xhtml 1.1 page.
However, there is a way around this. The server and browser exchange
information when they first connect. The server can ask the browser if
it can handle the correct mime type for true xhtml. This is taken care
of by a php include at the very top of the page that replaces
everything above the head tag of the page, and the page is given an
extension of .php . The include is the same for different pages, so it
is just a 3 line external link to the php code used on all pages. If
the browser likes xhtml, the php on the server writes all of the code
above the head tag required for xhtml 1.1, and that is what you see
when you view the source of the page on a recent Mozilla family or
Opera browser. However, if the browser does not like xhtml, then the
code above the head tag is written as html 4.01 strict, which is what
you see if you view the source of the page on an IE6 and some older
browsers. However, since the page is written for xhtml, everything such
as <br /> must be converted to <br> to satisfy html 4.01 strict. This
is done by a regular expression in the php code. Of course you need to
check the page on IE6 to make certain that the code gets converted
correctly and validates, but you need to check any page on IE6 anyway
as well as on more modern browsers, and it only adds a minute or two to
right click, copy the source, take it to the W3C validator, and paste
it in a text box to validate as html 4.01 strict.

There can be complications if you use some javascript. For example,
document.write is not allowed in xhtml 1.1 and use of it may cause the
page not to display or just give an xml error message. The page is
parsed as xml when you serve it correctly, and there is no telling what
a document.write might generate such as unclosed tags which are fatal
for some xml applications. Thus document.write can not be allowed.
However this can be overcome by writing some of the script in php on
the server which then downloads what the document.write would have
generated on the browser, so the xml parser is happy and can check
everything for closing tags etc.

I have written well over 100 pages in html 1.1 that are served
correctly. Once you have done this several times, it takes very little
more time that using html 4.01 strict, so for me it is no longer a big
deal. My only advice is that if you use xhtml 1.1, do it right. Else
stick with html 4.01 strict.

The reason for xhtml is to make PC html code XML pure. There are now
many other computing devices, and XML has become the standard for
information exchange between them. Xhtml 1.1 greatly improves the XML
purity, but it still does not go quite far enough. The higher levels of
xhtml in the works will require new browsers.

What code you should be using depends on your background and what kind
of pages you write. If you work for someone else, the code you should
use is what they demand, although some bosses are open to suggestion.
If you are your own boss, there are many options. If you are writing
general pages to sell things to a wide variety of people, you usually
can not get too exotic in the code you use. If you are writing for a
network where you can control everything, you can use about any kind of
code you wish. And there are many other levels between these two
extremes.

 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      01-13-2006
cwdjrxyz wrote :


> However, IE6 will not display a true xhtml page served correctly, and
> rumor has it that neither will the upcoming IE7.


It's official:

"I've also been reading comments for some time in the IEBlog asking for
support for the "application/xml+xhtml" MIME type in IE. I should say
that IE7 will not add support for this MIME type (...) Why aren't we
supporting XHTML when it's served as the "application/xml+xhtml" media
type in IE7? I made the decision to not try to support the MIME type in
IE7 simply because I personally want XHTML to be successful in the long
run."
Chris Wilson, September 15th 2005
http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx

Gérard
--
remove blah to email me
 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      01-13-2006
Thanks for taking the time to write an extensive reply cwdjrxyz, please
see my comments.

cwdjrxyz wrote:
> The most important thing is that you use some valid type of html. Even
> old 3.2 would serve for very simple pages and is still understood by
> most browsers. However it is quite common for many pages from large
> corporations to be written in a html soup ranging from html 3.2 to
> xhtml levels. Some such pages likely were started many years ago and
> just added to by various people over the years. It is no surprise that
> some such pages have problems with some common browsers and often fail
> and must be patched at new browser upgrades.


We always validate our (X)HTML markup and CSS styling, and I'm all to
aware of the html soup websites you refer to - we're often asked to work
on websites like this and we usually say that it would be cheaper for us
to start from scratch and build the website again.

> Concerning xhtml 1.1, it can be used if you make the effort to learn it
> well. At a minimum, in addition to writing valid html 1.1 code, you
> must set up your server to serve the page with the mime type of
> application/xhtml+xml associated with the extension .xhtml, or you can
> also serve as .xml. If you serve a page written in valid xhtml with the
> extension .html on most servers, you are just serving the page as html
> and might as well use 4.01 strict. When you serve true xhtml 1.1 with
> the proper mime type, you will find that it will be viewed well on the
> recent Mozilla family browsers(Firefox, Mozilla, and Netscape) and
> Opera. There are a few bugs in some browsers that can be overcome, such
> as a CSS body background color one on the Mozilla family browsers.


Regarding serving an XHTML page with a different mimetype, why should we
do this? Is it because the browsers do not understand the XHTML
extension? Most of our pages have a .php extension, so what happens in
these cases - what mimetype would the server pass? How would the
browser interpret it?

> However, IE6 will not display a true xhtml page served correctly, and
> rumor has it that neither will the upcoming IE7. You could write a
> special page for IE in html 4.01 strict as well as the xhtml 1.1 page.
> However, there is a way around this. The server and browser exchange
> information when they first connect. The server can ask the browser if
> it can handle the correct mime type for true xhtml. This is taken care
> of by a php include at the very top of the page that replaces
> everything above the head tag of the page, and the page is given an
> extension of .php .


I understand your logic, but what about when a user has the ability to
use HTML in a webform which will then be displayed on the website? How
do you make sure this is valid and inline with the doctype being used?
Isn't that a bit overkill?

> There can be complications if you use some javascript. For example,
> document.write is not allowed in xhtml 1.1 and use of it may cause the
> page not to display or just give an xml error message. The page is
> parsed as xml when you serve it correctly, and there is no telling what
> a document.write might generate such as unclosed tags which are fatal
> for some xml applications. Thus document.write can not be allowed.
> However this can be overcome by writing some of the script in php on
> the server which then downloads what the document.write would have
> generated on the browser, so the xml parser is happy and can check
> everything for closing tags etc.


Generally we don't use JavaScript, but an exception would be Google
AdSense banners which give you some JS to incorporate to display the
banner - again - how do we know that this JS is inline with our doctype?

> I have written well over 100 pages in html 1.1 that are served
> correctly. Once you have done this several times, it takes very little
> more time that using html 4.01 strict, so for me it is no longer a big
> deal. My only advice is that if you use xhtml 1.1, do it right. Else
> stick with html 4.01 strict.
>
> The reason for xhtml is to make PC html code XML pure. There are now
> many other computing devices, and XML has become the standard for
> information exchange between them. Xhtml 1.1 greatly improves the XML
> purity, but it still does not go quite far enough. The higher levels of
> xhtml in the works will require new browsers.


I've written most of my pages in XHTML 1 Strict or Transitional over the
last 2 years. I've never noticed any bugs which can be attributed to my
choice of doctype, but then, maybe I wouldn't notice that...?

> What code you should be using depends on your background and what kind
> of pages you write. If you work for someone else, the code you should
> use is what they demand, although some bosses are open to suggestion.
> If you are your own boss, there are many options. If you are writing
> general pages to sell things to a wide variety of people, you usually
> can not get too exotic in the code you use. If you are writing for a
> network where you can control everything, you can use about any kind of
> code you wish. And there are many other levels between these two
> extremes.


I run a small company and one of our services is web development for
local businesses. We host our own websites, so we have server root
access and the freedom to do things as we wish.

My main reason for asking was because I'm currently programming a big
CMS for our use (we won't be distributing it), and it will be one script
outputting every page, so I wanted to make sure I used the best doctype
for the job from the start.

Any more info or advice would be much appreciated.

Marc
 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      01-13-2006
Gérard Talbot wrote:
> type in IE7? I made the decision to not try to support the MIME type in
> IE7 simply because I personally want XHTML to be successful in the long
> run."
> Chris Wilson, September 15th 2005
> http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx


How does deciding not to support that doctype in IE7 make XHTML
'successful in the long run'? I don't follow...

Marc
 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      01-13-2006
Gérard Talbot wrote:
> The most important thing is to write with a strict DTD. Strict DTD will
> bring all modern browsers (they all do support rendering mode based on
> doctype declaration) into web standards compliant rendering mode. In
> case of MSIE 6, this is very important to do since MSIE 6 in standards
> compliant rendering mode will implement correctly the CSS box model.


Does this mean that browsers actually take note of the doctype and
interpret the markup differently? Sorry if that sounds a really dumb
question...

> Overall, strict DTD disregards elements and attributes used for
> presentational/style purposes: your markup code makes better (or more
> correct) use of the HTML code in its original intent, in its best
> intended purpose. Usage of elements like <font>, <center>, etc. and
> attributes like bgcolor, vspace, etc. are formally deprecated and should
> be replace by use of CSS.


That's okay, we don't use any of the elements or attributes you
mentioned, and use CSS for presentation as it is intended. There is one
attribute I have not yet found an alternative to...

<img src="" align="right" />
<p>Big long paragraph of text</p>

This makes the text wrap around the image, is there a CSS alternative to
this?

> Reasons why HTML is to be preferred to XHTML are mentionned in 2 well
> written documents:
>
> Sending XHTML as text/html Considered Harmful
> http://www.hixie.ch/advocacy/xhtml
>
> Say NO to XHTML
> http://www.spartanicus.utvinternet.ie/no-xhtml.htm


Thank you, I shall have a read through these documents when I get some
time.

Marc
 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      01-13-2006
Andy Dingley wrote:
> Recommendations:
>
> Don't use XHTML 1.1 or 2.0


Why not?

> If you do use XHTML, use Appendix C.


Sorry, I'm not clear on what you mean by 'Appendix C'. Please could you
explain?

> Use Strict (either one), because it keeps IE's CSS rendering models
> under control. IMHO it's better to be slightly invalid (with <a
> target="" > etc.) than to lose Strict in favour of valid Transitional.


Is it only IE that the choice of Transitional/Strict affects?

> Coding style depends on more than doctype. <font> will either be there
> or it won't, depending on whether you use it. Using Transitional doesn't
> make it compulsory!


I always use CSS for presentation, so I wouldn't touch <font> with a
barge pole.

> There's also no reason why a site needs a consistent doctype. If it's
> hard to do it on a particular page, change doctype.


Unless you're writing a CMS from which all pages will be outputted in
the same format.

> XHTML is hard to generate from XSLT - if you're using Appendix C. You
> may find HTML easier to keep valid. XHTML-as-XML (as generated by XSLT
> with <xslutput mode="xml" > ) is not a good choice for the web - it
> certainly will cause problems.


Sorry, you lost me completely there, I've not looked into XSLT yet.

> As to which is better, HTML 4.01 vs. XHTML 1.0 / Appendix C, then there
> just isn't anything clear to choose between them. If there was, then we
> wouldn't need to argue over it.


But arguing makes for good discussion!

Marc
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs XML 0 08-02-2011 05:40 AM
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs C Programming 0 08-01-2011 06:29 AM
convert xhtml to another xhtml using xslt Usha2009 XML 0 12-20-2009 01:13 PM
Should I Convert Site To XHTML or XHTML mobile? chronos3d HTML 9 12-05-2006 04:46 PM
parse URL (href) from xhtml, xhtml -> text, for data hawat.thufir@gmail.com XML 7 02-08-2006 07:39 PM



Advertisments