FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

XHTML, HTML and standards

 


Donutey
I was wondering how many people try to get their sites at least moderately standards compliant, and if anyone has moved to XHTML or stayed with HTML and why.

I recently redesigned my site in valid XHTML and other than changing a couple hundred <br /> tags in some old content it wasn't that bad. (control v is the best. Rolling Eyes )
romaop
At the beginning of my sites I've got:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

I'm not a specialist but read some articles in a site made by a person from a CSS team. He says that Internet Explorer latest releases are bad unless you use the standards, because you avoid one thing called the Quirks mode. Some things must be done in a CSS file to make browsers do the same formating, because they have different defaults.
I've also heard a person that wanted to use a flash movie that only worked with a standard.
So yes, it's important to go for standards if you're concerned in a more viewed and reliable site.
Another aspect is the coding skill and testing, which I found essential to correct different layouts in different browsers or other difficulties.
For instance, I was updating a site built with frames and added some javascript. The javascript did it's job but had a nasty side effect. I didn't realise what was wrong. Things that worked well just ended doing so. Some links didn't show up anymore at the right frame. So I found some span tags that perhaps could be avoided. Making each link in a different cell table the problem just disappeared. Surprise!
Kaneda
It's true that Internet Explorer 6 and 7 will behave best when you follow the standards, and specifically when you have a proper DOCTYPE. This is because IE (and other browsers) specifically use the DOCTYPE at the start of the page to switch from "quirks mode" into "standards mode". This is in order to keep backward compatibility while still allowing newer sites to "do things right". Remove the DOCTYPE, and the width of boxes etc. will be different.

However, HTML 4.01 will be just fine (actually better) than XHTML for IE, with a doctype like:

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


Since IE quite simply doesn't support XHTML at all. It will see a well-formed, valid XHTML document as a document stuffed with errors - errors which it then tries to ignore - but which will (somewhat) make the page actually render slower.

Also, if you say you aren't a specialist, I'd encourage you to use that doctype instead Wink Because your site is very unlikely to be valid XHTML 1.1. To be that, it has to be sent to the browser as XML, not HTML, and this will make IE not display the site at all.

As for Flash, it's actually almost impossible to get Flash to work at all in all browsers in any HTML standard, if you put the Flash embedding inside the HTML - but you shouldn't anyway, since a new IE update has made it essential to only include Flash (and QuickTime, Windows Media Player, Shockwave etc.) through JavaScript - otherwise you'll get a "Click here to activate content" problem. Reason: Mozilla browsers mainly recognize the EMBED element for plugin object embedding, and EMBED isn't a part of any HTML standard. Hence, if you make it work in Mozilla, it won't be standards compliant anymore.

Standards are a complicated issue right now, and I'd say, about 80-90% of people who claim to write by "strict standards" actually don't. A proper XHTML page, especially when served as XML, offers lots of new things the designer has to get past:

- CSS behaves slightly differently (<body> no longer fills the entire browser window, so you have to style <html>).
- Javascript behaves differently - tag names used in it are now case-sensitive among other things. Google Maps API, for example, doesn't work on an XHTML page served as XML at the moment.
- You can't use entities (like &shy; or &cpy; ) - XML only supports 5 entities: &amp; &apos; &quot; &lt; and &gt; - all others have to be numeric (like &#128 ) or you have to declare them yourself (and don't expect browsers to understand that).
- Any javascript inside your HTML file generally (if it includes < or &, and most javascript does) needs to be escaped with <![CDATA[ javascript here ]]>
- Finally stopping to use those non-existant attributes and element names (<embed>, target="_blank" etc.)
- many other things.

For many people, it's clearly hard enough to get used to the strict XML way of doing things - all lowercase, closing tags, closing empty tags even, etc. Smile That's the reason why at least 50% of XHTML pages on the web don't actually validate. Then add the idea that there are some tags they shouldn't use (those that they never should have been using in the first place), and things start to get ugly. Then tell them to "try and tell the browser that your page is XML now", and watch them go insane Smile

For most hobby web developers, going to XHTML is pretty useless, and for now, they might as well stick with HTML 4.01 Wink

The more important parts of web standards for "normal people" right now would be CSS, content/presentation/behaviour separation etc.
Stubru Freak
Kaneda wrote:
It's true that Internet Explorer 6 and 7 will behave best when you follow the standards, and specifically when you have a proper DOCTYPE. This is because IE (and other browsers) specifically use the DOCTYPE at the start of the page to switch from "quirks mode" into "standards mode". This is in order to keep backward compatibility while still allowing newer sites to "do things right". Remove the DOCTYPE, and the width of boxes etc. will be different.

However, HTML 4.01 will be just fine (actually better) than XHTML for IE, with a doctype like:

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


Since IE quite simply doesn't support XHTML at all. It will see a well-formed, valid XHTML document as a document stuffed with errors - errors which it then tries to ignore - but which will (somewhat) make the page actually render slower.

Also, if you say you aren't a specialist, I'd encourage you to use that doctype instead Wink Because your site is very unlikely to be valid XHTML 1.1. To be that, it has to be sent to the browser as XML, not HTML, and this will make IE not display the site at all.

As for Flash, it's actually almost impossible to get Flash to work at all in all browsers in any HTML standard, if you put the Flash embedding inside the HTML - but you shouldn't anyway, since a new IE update has made it essential to only include Flash (and QuickTime, Windows Media Player, Shockwave etc.) through JavaScript - otherwise you'll get a "Click here to activate content" problem. Reason: Mozilla browsers mainly recognize the EMBED element for plugin object embedding, and EMBED isn't a part of any HTML standard. Hence, if you make it work in Mozilla, it won't be standards compliant anymore.

Standards are a complicated issue right now, and I'd say, about 80-90% of people who claim to write by "strict standards" actually don't. A proper XHTML page, especially when served as XML, offers lots of new things the designer has to get past:

- CSS behaves slightly differently (<body> no longer fills the entire browser window, so you have to style <html>).
- Javascript behaves differently - tag names used in it are now case-sensitive among other things. Google Maps API, for example, doesn't work on an XHTML page served as XML at the moment.
- You can't use entities (like &shy; or &cpy; ) - XML only supports 5 entities: &amp; &apos; &quot; &lt; and &gt; - all others have to be numeric (like &#128 ) or you have to declare them yourself (and don't expect browsers to understand that).
- Any javascript inside your HTML file generally (if it includes < or &, and most javascript does) needs to be escaped with <![CDATA[ javascript here ]]>
- Finally stopping to use those non-existant attributes and element names (<embed>, target="_blank" etc.)
- many other things.

For many people, it's clearly hard enough to get used to the strict XML way of doing things - all lowercase, closing tags, closing empty tags even, etc. Smile That's the reason why at least 50% of XHTML pages on the web don't actually validate. Then add the idea that there are some tags they shouldn't use (those that they never should have been using in the first place), and things start to get ugly. Then tell them to "try and tell the browser that your page is XML now", and watch them go insane Smile

For most hobby web developers, going to XHTML is pretty useless, and for now, they might as well stick with HTML 4.01 Wink

The more important parts of web standards for "normal people" right now would be CSS, content/presentation/behaviour separation etc.


Altough you are right and HTML is the choice for professional websites in my opinion (more compatible), strict XHTML looks much cleaner, because of the closing of all tags.

Also, an XML parser which has never heard of XHTML, will be able to parse it (into a tree, for example), however it is impossible to make an XML parser that will parse any HTML without knowing some information about every tag.

This makes XHTML the language of the future, so it's really useful to learn. If you send it as text/html, it isn't completely strict, but whatever! If you don't do this IE won't parse it, Mozilla has difficulties with it (they officially recommend to send it as text/html instead of application/xhtml+xml) and probably almost all browsers have.

So the advantage of text/html xhtml is clear: being a little innovative without going too far.

So I put my limit here:
Make sure the W3C Validator succesfully validates my page. The W3C probably will add a "wrong MIME-type" alert when they think the time is right.

And one last note:

In XHTML 1.0 (even Strict), text/html can be used as the MIME-type for compatibility reasons. (Only with HTML compatible XHTML)
In XHTML 1.1 this isn't allowed anymore.

Summary:
http://www.w3.org/TR/xhtml-media-types/#summary
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.