Microsoft's official breed of HTML as spit out by Office 97 and Office 2000. In addition to assuming the Windows-1252 character set is used by all browsers (leading to ? appearing in lieu of smart quotes and other such extended characters in Mozilla et al) it uses a perverse blend of CSS to put lots of stylistic information everywhere possible.

While MS-HTML renders just fine in Internet Explorer 5, and Mozilla can strip away most of the bloat fine, other browsers like Netscape 4 have a very hard time dealing with it. Furthermore, it is extremely large and impossible to maintain if you prefer to work in plaintext. By offloading formatting to a separate, 1 KB style sheet, I was able to reduce the size of one MS-HTML file by about 80% when converting it to straight HTML. On a corporate intranet such bloat doesn't take very long to load, but modem users will be frustrated as precise table rendering code takes eons to download.

Open Microsoft Word. Type Hello, World!. Click Save as Web Page. Choose a file name. Look at the file. It is 1.54 KB. It looks like the same as the following code:

<title>Hello, world</title>
Hello, world!

And that's for 13 characters of text.

Thanks to xriso for pointing out a typo.
As a person who worked on the HTML engine inside of Microsoft Office, there is a large reason why there is so much bloat inside of a file generated by MSO. The point of saving a document to HTML is document data fidelity, and document display fidelity. When you are talking about Office in this case, you mean Microsoft Word, as each product has it's own conventions for saving as HTML.

The HTML output by Microsoft Office is about 90% compatible with Netscape Navigator, with a few exceptions:
  • Embedded movies and media tend to end up as <img dynsrc=... which is an IE only specification. They should end up as <embed src=... but that's a personal gripe I had.
  • Some meta tags mean nothing to Netscape
  • Some of the CSS and other positioning things only matter in IE 5.0 and above.
  • OLE objects tend to be a little weird
  • Some of the other programs use JavaScript that isn't 100% compliant with Netscape, but do work.

I took a Microsoft Word 2000 Document and saved as HTML. The entire contents of the document were "Hello World", in the true style of CS. Here's what I got:
<html xmlns:o="urn:schemas-microsoft-com:office:office"

You'll see this XML all over the place. This is for future compliance and for use in the Microsoft XML parsing engines. You could also script against yourself this to see what HTML you'll be seeing. It's useful for anyone wanting to parse the information.

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">

These are your standard meta tags, except ProgId. This is a COM name identifier that tells what kind of document you're looking at. Therefore if you open up a Microsoft Word generated HTML file in Excel, it will know not to parse it, but to launch Word to handle that. The charset in the http-equiv is telling what codepage to be looking at for the character set. Word is incredibly picky about the fonts and characters.

<link rel=File-List href="./Hello%20world_files/filelist.xml">

Ahh, our first bit of strangeness here... You will notice that this is a relative path to something that simply doesn't exist. (It is ignored in this case) It would however exist if you had embedded files in the document, or any images. This retrieves a list of everything that the word doc contained (whether it be an OLE object, a file that just isn't visible, etc). When you save out to HTML, with images, you notice that there is a folder oftentimes created with the document named "documentname"_files. This contains all of those items. Here, because the doc is so simple, this isn't an issue.

<title>Hello world</title>

Your title is right there. Nothing strange at all

<!--[if gte mso 9]><xml>
  <o:Author>Jay Bonci</o:Author>
  <o:LastAuthor>Jay Bonci</o:LastAuthor>
  <o:Company>Manifest Research Visions, Inc.</o:Company>

Word keeps a section of the document properties, including who wrote the document, lines, when it was created, etc. Whenever you save as HTML, each of these items are kept in this XML section inside of the document. They are used to describe the document and preserve the information across file format change.

 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;

This is non-standard CSS to preserve some of the items that CSS doesn't describe, but obviously Word needs. For instance you see mso-header-margin is obviously the number inside of Page Setup off of the File menu.


<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal>Hello world</p>




There, that seems to be all of it. Word takes many many steps to make sure that the document is as preserved as possible and that HTML is a lossless format. If you pick apart more complicated documents you'll notice that your data is held intact across this format very well, and that was the design goal. This has all been explained before in a public forum, and I'm not giving away any proprietary secrets of this four year old feature.

Actual hand HTML editing is done very rarely by a person who would save as HTML in Word. Bascially, you are looking at a business person who wants to save to the Web, most likely a corporate intranet. In the Macintosh Office 2001 version of the product, there is a save option off of the Save Dialog that allows you to save as "clean" HTML without the Microsoft specific tags (but you lose information in the conversion back to the web.)

Log in or registerto write something here or to contact authors.