Forum Moderators: open
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]
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.
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.
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.
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?