2013-02-13 1:05, Alfred Molon wrote:
> In article <timstreater->, Tim
> Streater says...
>> In article <>,
>> Alfred Molon wrote:
>>
>>> Should one declare HTML pages as HTML 4 strict or HTML 5?
>>>
>>> In other words use this header
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>> "http://www.w3.org/TR/html4/strict.dtd">
>>>
>>> or this one
>>> <!DOCTYPE html>
[...]
>> All that matters is that you either have a doctype or you don't.
As far as browser behavior is considered, the two specific doctype
strings above have exactly the same effect. In markup validation, they
make a huge difference. However, validators have a "doctype override"
feature.
As a general statement, "All that matters is that you either have a
doctype or you don't" is not correct at all. Different doctype strings
trigger different browser modes, see
http://hsivonen.iki.fi/doctype/
>> These days, just use <!DOCTYPE html> everywhere.
If you don't care about validation and your pages are ready for
Standards Mode (old pages generally aren't), then <!DOCTYPE html> is
simplest. The simplicity helps to avoid stupid mistakes in the doctype
string - a single mistyped character there can have drastic effects.
> So it's irrelevant?
Not at all if validation is considered.
> Do pages which validate as HTML 4 strict also validate as HTML 5?
No, that's a common misconception. Some examples of valid HTML 4.01
Strict features that cause an error message in HTML5 validation:
- the <acronym>, <big>, and <tt> elements
- <object> element inside <head> element
- several attributes, e.g. align=right in <td>
- <meta> tags in general: HTML 4.01 syntax is very liberal, allowing
<meta name=myidea content=whatever>, whereas HTML5 specifies a (messy)
mechanism for defining allowed variants and declares all the rest invalid.
The bottom line is: decide whether your documents will be closer to
HTML5 than to (some variant of) HTML 4.01, and select the doctype string
accordingly. This is just a practical issue: which choice gives your
fewer disturbing error messages about constructs that you use knowingly,
so that it is easier to check out the other messages (which may reveal
real errors)?
--
Yucca,
http://www.cs.tut.fi/~jkorpela/