Richard D. Worth wrote:
Best practice, valid HTML, and compatible with XHTML would be $('#whatever').html('<div></div>'); $('#whatever').html('<br />'); $('#whatever').html('<img alt="" src="..." />');
Well, not quite "valid" HTML... If you use "<br />" in an HTML 4.01 page, the validator at "w3.org" gives a warning with the following explanation: The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag <FOO (with an implied '>'). However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML. That means that "<br />" is valid, but it does not mean what it was supposed to mean (in HTML 4.01). It means "<br>>"! Still, it's not likely that any browser will actually produce "<br>>" "from $('#whatever').html('<br />')". But we're talking "best practices" here. -- Bertilo Wennergren <http://bertilow.com>