Reputation: 715
We're currently working with a system (for better or worse) that declares a doctype as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The trouble is, many of our users, who will be writing content, are used to using XHTML-style tags like <br />
, or <img ... />
, instead of those that strictly should be used (i.e. <br>
and <img>
).
My question is, what is the real-world effect of this on a browsers rendering capability, and on semantics?
My first inclination is that it's a) not fair on the browser to throw this at it and expect it to bend over backwards and to know what to do, and b) removes the "guarantee" that any browser today or in the future will know how to display our pages correctly.
The page appears outwardly fine (although looking at the source code makes me shudder), but is this having some more sinister effect that isn't immediately apparent?
Upvotes: 0
Views: 121
Reputation: 201896
The question appears to be about “self-closing” tags in HTML 4.01, rather than the much more general question in the heading. The answer is that they have no effect on browsers and it is highly unlikely that this would change, given the vast amount of such code around.
Technically, <br />
and <img ... />
are not invalid in HTML 4.01. HTML has formally been defined so that due to certain syntactic specialties, these constructs mean the same as <br>>
and <img ...>>
(where the final >
is a data character). Browsers do not implement HTML this way; instead they just treat the /
as an unrecognized and therefore discarded part of the tag.
Upvotes: 1
Reputation: 318808
Browsers simply don't care about things like that. They usually even support attributes that simply do not exist in the given doctype (<a target="...">
in XHTML strict).
However, if you use XHTML with an XML content-type they may use an XML parser which will be strict and throw an error if you do invalid things - IE is known to behave like this.
Upvotes: 2