Style Definitions

Each style defined within a WordprocessingML document requires a style definition. The style definition contains all of the information needed by a consumer to store and display that style within a WordprocessingML document, and is defined using the <style> element. The style definition for any style in WordprocessingML can be divided into three segments (Note: the complete definition of style properties can be found on the reference for the <style> element):

  • Common style properties

  • Style ‘types’

  • Type specific properties

Common style properties refer to the set of properties which can be used regardless of the type of style; for example, the style name, additional aliases for the style, a style ID (used by the document content to refer to the style), if style is hidden, if style is locked, etc.

Consider a style called Heading 1 in a document as follows:

<w:style w:type="paragraph" w:styleId="Heading1">
  <w:name w:val="heading 1"/>
  <w:basedOn w:val="Normal"/>
  <w:next w:val="Normal"/>
  <w:link w:val="Heading1Char"/>
  <w:priority w:val="1"/>
  <w:qformat/>
  <w:rsid w:val="00F303CE"/></w:style>

Above the formatting information specific to this style type are a set of common style properties which define information shared by all style types.

Style types refer to the property on a style that defines the type of style created with this style definition. WordprocessingML supports six types of style definitions:

  • Paragraph styles

  • Character styles

  • Linked styles (paragraph + character)

  • Table styles

  • Numbering styles

  • Default paragraph + character properties

Consider a style called Heading 1 in a document as follows:

<w:style w:type="paragraph" w:styleId="Heading1">
  <w:name w:val="heading 1"/>
  <w:basedOn w:val="Normal"/>
  <w:next w:val="Normal"/>
  <w:link w:val="Heading1Char"/>
  <w:priority w:val="1"/>
  <w:qformat/>
  <w:rsid w:val="00F303CE"/></w:style>

The @type attribute has a value of paragraph, which indicates that the following style definition is a paragraph style.