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.
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 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.|
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.
To store the author's name for a given comment, Word and Excel use the mso-comment-author style attribute.
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.
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.
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.|
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.
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.