Forum Moderators: open

Message Too Old, No Replies

HTML or XHTML, Strict or Transitional

a few questions on this

         

HelenDev

1:54 pm on Nov 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is partly in response to an older (locked) thread at [webmasterworld.com...]

Back when I learnt to code HTML, there seemed to be the feeling that XHTML was the way forward, and we should all be going in that direction. While I've been off busy working on websites, it seems that this thought has swung back in the other direction and that HTML is now the way to go again. I'm sure the reasons for this are sound, so I don't particularly need to have that discussion and I probably wouldn't understand it anyway! :)

One question I do have though, it was always drummed in to me to 'close' tags such as <br /> <img /> etc., as it's the 'xml' way to close all tags. I still do it. Should I stop it? It's got me into hot water a couple times doing it with metatags.

On a related topic, now that we're all going back to HTML, I was wondering about the HTML strict doctype. In encyclo's previous post it says


HTML 4.01 Strict is the recommended choice when:
  • You are using CSS for layout and presentation
  • You want to improve the accessibility of your page
  • You are catering for modern browsers (including IE6)
  • You want your page to work in alternative devices (mobile phones, consoles)
  • You want to improve your content-to-code ratio
  • You don't need presentational HTML

I understand about the not using presentational HTML, and the content-to-code ratio, but I'm a bit unclear on some of the others.

If I changed all my pages which currently validate to the HTML 4 transitional doctype, to the strict doctype today, would I notice any differences? If, so what might happen? Might something bad happen in older browsers?

How is strict any different from transitional when displaying in different devices? I already use device specific stylesheets.

Why and how does it improve accessibility? Is this related to the devices issue above?

I look forward to finding out more about this!

[edited by: HelenDev at 1:59 pm (utc) on Nov. 15, 2006]

Robin_reala

5:17 pm on Nov 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I changed all my pages which currently validate to the HTML 4 transitional doctype, to the strict doctype today, would I notice any differences? If, so what might happen? Might something bad happen in older browsers?

No, you won't notice any difference (unless you're relying on 'Almost standards mode' in Gecko [developer.mozilla.org]). They might stop validating though.

How is strict any different from transitional when displaying in different devices? I already use device specific stylesheets.

Not sure if I understand this question.

Why and how does it improve accessibility? Is this related to the devices issue above?

It's related to the enforced lack of presentational information in HTML Strict.

encyclo

5:19 pm on Nov 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why and how does it improve accessibility?

There's nothing with the doctype itself which has any impact on accessibility. However, when you are validating against a strict doctype such as HTML 4.01 Strict or XHTML 1.0 Strict, then the fact that deprecated presentational elements and attributes are invalid helps you to create markup which is clean and naturally more accessible. A stricter standard pushes you into having an improved development process.

I would say that if you are happy and more at ease using XHTML syntax and an XHTML doctype, then you can continue to use it. Just don't try to serve it with any other mime type than

text/html
(i.e. as standard HTML). However the recent news that the W3C is restarting HTML development [webmasterworld.com] confirms that XHTML has not had the success hoped for a few years ago. We (myself included) thought that XHTML would take over, but we were proved wrong.

If you decide that you want to use HTML rather than XHTML, then you should use HTML syntax - which means that you shouldn't use trailing slashes on meta elements, image elements, line breaks, etc. If you have pages already on line and working well using XHTML 1.0, don't waste time trying to convert them back to HTML4 - they can stay in XHTML.

floriniri

6:32 am on Nov 18, 2006 (gmt 0)

10+ Year Member



I first used XHTML, but I was having a hell of a time correcting it. So I use HTML 4.0 for all my sites. I can use css to it's full capabilities and it's fairly easy.
Just my 2 cents

romaniucc

7:32 am on Nov 18, 2006 (gmt 0)

10+ Year Member



I use XHTML because that's the language I'm used to. And don't lough, I use Dreamweaver as well.

penders

12:37 pm on Nov 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I first used XHTML, but I was having a hell of a time correcting it. So I use HTML 4.0 for all my sites. I can use css to it's full capabilities and it's fairly easy.

Are you implying that you can't 'use CSS to the full' if use XHTML syntax? Surely there is no difference as far as CSS is concerned?

mattur

1:29 pm on Nov 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



penders, I suspect that floriniri was just re-iterating the point that you don't have to use XHTML to use CSS to its full capabilities.

When the Web Standards movement began evangelising XHTML and CSS, some folks misunderstood this to mean that to fully use CSS required the use of XHTML markup. As you point out, this isn't the case.

HelenDev

1:40 pm on Nov 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the info, guys :)

How is strict any different from transitional when displaying in different devices? I already use device specific stylesheets.
Not sure if I understand this question.

I was just wondering why encyclo said...

HTML 4.01 Strict is the recommended choice when... You want your page to work in alternative devices (mobile phones, consoles)

Perhaps it is just because of the cleaner code, removal of presentation benefits talked about previously, that this makes it easier to create device specific stylesheets?

if you are happy and more at ease using XHTML syntax and an XHTML doctype

I'm using an, er, HTML loose doctype, and *ahem* XHTML syntax. I'm guessing that's not good practice then - I'll try and stop it! Is there some sort of herbal remedy or gum I could try for this? ;) Or perhaps switching to HTML strict would do it?