Microsoft Word and Microsoft Excel both have comment features, but they are slightly different in each program. However, both programs save their comments to HTML in the same way. PowerPoint does not have this feature; rather, it uses the notes feature on each slide.

Comments in HTML documents created with Word and Excel display differently depending on whether the browser used to display the document supports dynamic content. Scripting is used to detect the browser at load time. In Microsoft Internet Explorer 4.0 and later browsers, comments are dynamic. They pop up like a tooltip when the cursor is positioned over the comment reference. The comments are formatted using CSS to look like post-it notes. Visibility is dynamically toggled through JavaScript event handlers.

In other browsers, comments are static. They are displayed at the bottom of the Web page, much like footnotes and endnotes. Comments and their anchors are hyperlinked for easy browsing between them.

Word and Excel HTML comments have the following distinct components.

Comment component Description
Comment data The data is the comment itself, which can contain richly formatted text, pictures, tables, and most other types of Office document data. When saved as HTML, Word and Excel store the comment data near the end of the Web page within a labeled Div element. The comment data is saved to HTML like standard Office document text.
Comment properties A set of Microsoft Office properties associated with a comment, such as the author's name, is saved in HTML by applying styles to the Div element containing the comment.
Reference The reference is the range of character positions in the main document that is associated with the comment. This range is saved in HTML by enclosing it within a labeled Span element. Multiple Span elements are used in the case where a comment's range overlaps the ranges of other comments.
Anchors Word and Excel include an anchor at the end of the comment reference and an anchor at the beginning of the comment data. The reference anchor provides a visual clue that a comment exists and that it is the nth comment made by a given author. In browsers that do not support dynamic content, the two anchors function as hyperlinks that let the user jump between the reference and the comment.


Comment references

Word and Excel use A elements to mark the text to which the comment was applied, and they use the mso-comment-reference style attribute to save the comment index and the author's initials to HTML. The comment index corresponds to the order of occurrence of the ends of comment references in the document, rather than their beginnings, because references can be nested with each other. Text-level elements cannot be overlapped in HTML, so they must be closed and reopened. In the situation of overlapping comment references, Word and Excel insert an additional style attribute, mso-comment-continuation.

Comment author name

To store the author's name for a given comment, Word and Excel use the mso-comment-author style attribute.

Comment text

All comments in a Word or Excel HTML document are stored inside a Div element labeled with the mso-element: comment-list style. Word and Excel position this element after the Div element containing the main document's last section and after any Div elements containing footnotes and endnotes. Inside the mso-element: comment-list style, Word and Excel store each comment in its own Div element with the mso-element: comment style.

Comment separator

The mso-element: comment-list style also contains an HR element to cleanly separate comments from preceding sections of the document in browsers other than Internet Explorer 4.0 and later.

<hr class=msocomoff align=left size=1 width="33%">

The separator is identical to the one used for footnotes and endnotes. The msocomoff style class dynamically formats the separator so it is not displayed in Internet Explorer 4.0 or later browsers.

Syntax for individual comments

The following table briefly describes the components of a comment Div element.

Comment Div element component Purpose
STYLE="mso-element: comment" A style that Word and Excel use to identify the Div element as the container of a comment.
CLASS=msocomtxt The msocomtxt style class is used to dynamically apply styles to all comments in a document.
ID=_com_n Unique identifier for the nth comment in a document; JavaScript code uses it to show and hide the comment region in Internet Explorer 4.0 and later browsers.
onmouseover="msoCommentShow('_anchor_n','_com_n')" Calls a JavaScript function that makes the comment with id=_com_n visible and displays it at the position of the anchor with id=_anchor_n. This guarantees that the comment remains visible when the user slides the cursor from the anchor onto the comment region.
onmouseout="msoCommentHide('_com_n')" Calls a JavaScript function that makes the comment with id=_com_n invisible when the user moves the cursor off the comment.

Comment anchors

When saving comments as HTML, Word and Excel provide comment anchors that help users view comments in the browser. In Internet Explorer 4.0 and later browsers, the anchors trigger pop-up display of comments. In other browsers, anchors function as two-way hyperlinks between the comment reference and comment data. The Span elements enclosing all comment anchors in the document have the msocomoff style class, which is used to dynamically hide the anchor string in Internet Explorer 4.0 or later browsers. The Span elements enclosing all reference anchors in the document have the msocomanchor style class. This is used to dynamically format all reference anchors for Internet Explorer 4.0 or later browsers through scripting.


When a Word or Excel document containing comments is saved as HTML, a Script element is placed within the Head element. The Script element contains scripting statements in JavaScript that make comments dynamic in Internet Explorer 4.0 or later browsers. Word and Excel HTML documents use scripting for two basic purposes:

Word and Excel documents also use scripting for browser detection so that comments can be dynamic for Internet Explorer 4.0 or later browsers. Browser detection is achieved using a JavaScript function, msoBrowserCheck( ), stored in the Script element contained in the head. The function accesses the name and version number of the browser by means of the navigator.appVersion object hierarchy. The function returns True if the browser is Internet Explorer 4.0 or later

If the browser detected is Internet Explorer 4.0 or later, special styles are applied to all comment elements in the document. The style rules are applied to elements having three style classes reserved for Office comments. 

For information about the style attributes that Office uses and their possible values, see the Style Attributes topic.