Jump to content

Rather confused: the page display even w/o <html>!


Saeed

Recommended Posts

Good Day,I am really baffled: I just saved a file with .htm extension but without <html></html> or <body> tags. And it works! I mean it gets displayed. Even a button can be placed and the onClick method would work. I'm using IE6; tried it with IE7, same thing. Even the little Perl script and "submit" worked (XAMPP is installed on the IE7 machine).There must be very good reasons for having those tags; please share them with me. Thanks.

Link to comment
Share on other sites

The <html> and </html> tells the browser that everything between them are html document.<body></body> tell the brwoser that everything b/t them are the main content.it is really important that you insert those <tags>. even if it work in IE6, that doesnt mean it will work in all IE versions and other browsers.

Link to comment
Share on other sites

The W3 consortium (the folks that make all the rules) are very insistent that browsers do whatever they can to display content. This is mostly for backward compatibility. There really are pages out there that have not been updated since 1994, and the W3C says browsers must find a way to make them work, just as they did in 1994 when the rules were very lax.It is also useful to display text that does not match an HTML standard because developers need a tool for testing code and displaying error messages. Often this means that output will not come in the context of a fully formed HTML document, or any HTML at all. If that functionality were removed, I and a lot of other people could not debug things like PHP scripts with any sort of efficiency at all.If you add, say, an HTML5 doctype, malformed content will not display. That's the rule for HTML5. The assumption is that you specified that doctype because you knew what you were doing, and if it breaks, that's your own fault.

Link to comment
Share on other sites

If you add, say, an HTML5 doctype, malformed content will not display. That's the rule for HTML5. The assumption is that you specified that doctype because you knew what you were doing, and if it breaks, that's your own fault.
What exactly does "malformed content" mean in this context? Markup that doesn't validate against the W3 validator? If that's the case, will PHP errors still display? I've seen many instances where PHP errors appear in places that break the validation rules...Or does "malformed content" simply mean missing <html>, <body>, or <head> tags?
Link to comment
Share on other sites

A "malformed" document does not follow the syntactic rules for the underlying markup language (SGML, XML) that it uses. This is opposed to "invalid", which just means the document does not validate against its specified DTD.Malformed XML:

<root>	<child>Blah</r>

Invalid (but well-formed) HTML 4.01:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"   "http://www.w3.org/TR/html4/strict.dtd"><form>	 <img src="something"></form>

In XML, malformed and invalid documents will not be parsed, at all, but in SGML, they will still "work". This is akin to how a car can still "work", even if you've given it vegetable oil instead of petrol, however.

Link to comment
Share on other sites

HTML 5 will render a document missing html and body tags as if they were there. Valid, but poorly formed HTML 5:

<!doctype html><title>This page is sucky</title><p>But it works!</p>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...