[Table of Contents] [docx version]

WordprocessingML Reference Material - Table of Contents

style (Style Definition)

This element specifies the definition of a single style within a WordprocessingML document. A style is a predefined set of table, numbering, paragraph, and/or character properties which can be applied to regions within a document.

The style definition for any style definition can be divided into three segments:

General style properties

Style type

Type-specific properties

General style properties refers 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.

[Example: 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 general style properties which define information shared by all style types. end example]

Style types refers to the property on a style which defines the type of style created with this style definition. WordprocessingML supports six types of style definitions by the values for the style definition's type attribute:

Paragraph styles

Character styles

Linked styles (paragraph + character) [Note: Accomplished via the link element (§2.7.3.6). end note]

Table styles

Numbering styles

Default paragraph + character properties

[Example: 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. end example]

Type-specific properties refers to the payload of the style: its formatting information as well as any properties which apply only to that type of style.

[Example: Consider a table style with primary name Normal Table defined as follows:

<w:style w:type="table" w:default="1" w:styleId="TableNormal">
<w:name w:val="Normal Table"/>

<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>

The tblPr element contains the formatting payload for this table style, which is only applicable to a table style. end example]

Parent Elements

styles2.7.3.18)

 

Child Elements

Subclause

aliases (Alternate Style Names)

§2.7.3.1

autoRedefine (Automatically Merge User Formatting Into Style Definition)

§2.7.3.2

basedOn (Parent Style ID)

§2.7.3.3

hidden (Hide Style From User Interface)

§2.7.3.4

link (Linked Style Reference)

§2.7.3.6

locked (Style Cannot Be Applied)

§2.7.3.7

name (Primary Style Name)

§2.7.3.9

next (Style For Next Paragraph)

§2.7.3.10

personal (E-Mail Message Text Style)

§2.7.3.11

personalCompose (E-Mail Message Composition Style)

§2.7.3.12

personalReply (E-Mail Message Reply Style)

§2.7.3.13

pPr (Style Paragraph Properties)

§2.7.7.2

qFormat (Primary Style)

§2.7.3.14

rPr (Run Properties)

§2.7.8.1

rsid (Revision Identifier for Style Definition)

§2.7.3.15

semiHidden (Hide Style From Main User Interface)

§2.7.3.16

tblPr (Style Table Properties)

§2.7.5.4

tblStylePr (Style Conditional Table Formatting Properties)

§2.7.5.6

tcPr (Style Table Cell Properties)

§2.7.5.8

trPr (Style Table Row Properties)

§2.7.5.11

uiPriority (Optional User Interface Sorting Order)

§2.7.3.19

unhideWhenUsed (Remove Semi-Hidden Property When Style Is Used)

§2.7.3.20

 

Attributes

Description

customStyle (User-Defined Style)

Specifies that this style is a user-defined style (i.e. it is not a style which was automatically generated by an application). This setting (specifically a value of true or its equivalents) shall not allow the formatting associated with the style to be changed automatically by an application, but may be used to specify that if the associated style ID is known, certain user interface behaviors may be applied to its definition. [Example: The style's primary name may be localized to match the current user interface language. end example]

 

If this attribute is omitted, then the style shall be assumed to be a built-in style.

 

[Example: Consider a paragraph style defined as follows:

 

<w:style w:type="paragraph" w:styleId="MyStyle" w:customStyle="true">
<w:name w:val="My Paragraph Style"/>
<w:rPr>
<w:b/>
</w:rPr>
</w:style>

 

This paragraph style specifies that it is a user-defined style using the customStyle attribute's value of true. An application may therefore take action on the style if it has behaviors associated with the style ID MyStyle. end example]

 

The possible values for this attribute are defined by the ST_OnOff simple type2.18.67).

default (Default Style)

Specifies that this style is the default for this type of style.

 

This property is used in conjunction with the type attribute to determine the style which is applied to objects that do not explicitly declare a style. [Example: The paragraph style with the default attribute set is the paragraph style applied to all paragraphs which do not explicitly reference a paragraph style using the pStyle element (§2.3.1.27). end example]

 

If this attribute is not specified for any style, then no properties shall be applied to objects of the specified type. If this attribute is specified by multiple styles, then the last instance of a style with this property shall be used.

 

[Example: Consider a paragraph style defined as follows:

 

<w:style w:type="paragraph" w:default="1" w:styleId="MyStyle" >
<w:name w:val="My Paragraph Style"/>
<w:rPr>
<w:b/>
</w:rPr>
</w:style>

 

This paragraph style specifies that it is the default paragraph style, and therefore all paragraphs which do not explicitly reference a paragraph style shall have this style applied.

 

For example, consider the following paragraphs from the same WordprocessingML document:

 

<w:p>
<w:pPr>
<w:pStyle w:val="Normal"/>
</w:pPr>

</w:p>

<w:p>

</w:p>

 

The contents of the first paragraph shall have the Normal paragraph style applied to them, while the contents of the second paragraph shall have the MyStyle paragraph style applied, since it does not explicitly reference a paragraph style and therefore inherits the default. end example]

 

The possible values for this attribute are defined by the ST_OnOff simple type2.18.67).

styleId (Style ID)

Specifies a unique identifier for the parent style definition. This identifier shall be used in multiple contexts to uniquely reference this style definition within the document.

 

[Example: The following are examples of elements which reference a style via its styleId attribute value:

To reference a style from content using elements like the pStyle element (§2.3.1.27), rStyle element (§2.3.2.27), and the tblStyle element (§2.4.59) for paragraphs, runs, and tables, respectively.

To link the paragraph and character versions of a style via the link element (§2.7.3.6)

To reference the parent style for style inheritance via the basedOn element (§2.7.3.3)

 

end example]

 

If multiple style definitions each declare the same value for their styleId, then the first such instance shall keep its current identifier with all other instances being reassigned in any manner desired. This reassignment shall not require references to those style definitions to be 'repaired' in the content (i.e. some content may lose its style definition information, since the document was ill-formed).

 

If this attribute is not specified, then a style ID may be assigned in any manner desired.

 

[Example: Consider a paragraph style defined as follows:

 

<w:style w:type="paragraph" w:styleId="MyStyle" >
<w:name w:val="My Paragraph Style"/>
<w:rPr>
<w:b/>
</w:rPr>
</w:style>

 

This paragraph style specifies that its style identifier shall be MyStyle using the styleId attribute.

 

Now consider the following paragraphs from the same WordprocessingML document:

 

<w:p>
<w:pPr>
<w:pStyle w:val="MyStyle"/>
</w:pPr>

</w:p>

<w:p>

</w:p>

 

The contents of the first paragraph shall have the bold paragraph property applied to them because their paragraph properties specify that they shall inherit the paragraph style whose styleId is MyStyle therefore inheriting its properties using the rules of the style hierarchy. end example]

 

The possible values for this attribute are defined by the ST_String simple type2.18.89).

type (Style Type)

Specifies the type of style definition defined by this element. WordprocessingML supports six types of style definitions:

Paragraph styles

Character styles

Table styles

Numbering styles

Linked styles (paragraph + character)

Default paragraph + character properties

 

Each of the first four types corresponds to a different value in this attribute, and therefore defines the type of the current style. [Note: The last two types are unique in that they are not simply a style type: a linked style is a pairing of a character and paragraph style via the link element (§2.7.3.6); and the document default properties are defined via the docDefaults element (§2.7.4.1). end note]

 

If this attribute is not specified, then the default value shall be assumed to be paragraph.

 

[Example: Consider a style defined as follows:

 

<w:style w:type="paragraph" … >
<w:name w:val="My Paragraph Style"/>
<w:rPr>
<w:b/>
</w:rPr>
</w:style>

 

The type attribute value of paragraph specifies that this style definition creates a paragraph style. end example]

 

The possible values for this attribute are defined by the ST_StyleType simple type2.18.90).

The following XML Schema fragment defines the contents of this element:

<complexType name="CT_Style">

   <sequence>

   <element name="name" type="CT_String" minOccurs="0" maxOccurs="1"/>

   <element name="aliases" type="CT_String" minOccurs="0"/>

   <element name="basedOn" type="CT_String" minOccurs="0"/>

   <element name="next" type="CT_String" minOccurs="0"/>

   <element name="link" type="CT_String" minOccurs="0"/>

   <element name="autoRedefine" type="CT_OnOff" minOccurs="0"/>

   <element name="hidden" type="CT_OnOff" minOccurs="0"/>

   <element name="uiPriority" type="CT_DecimalNumber" minOccurs="0"/>

   <element name="semiHidden" type="CT_OnOff" minOccurs="0"/>

   <element name="unhideWhenUsed" type="CT_OnOff" minOccurs="0"/>

   <element name="qFormat" type="CT_OnOff" minOccurs="0"/>

   <element name="locked" type="CT_OnOff" minOccurs="0"/>

   <element name="personal" type="CT_OnOff" minOccurs="0"/>

   <element name="personalCompose" type="CT_OnOff" minOccurs="0"/>

   <element name="personalReply" type="CT_OnOff" minOccurs="0"/>

   <element name="rsid" type="CT_LongHexNumber" minOccurs="0"/>

   <element name="pPr" type="CT_PPr" minOccurs="0" maxOccurs="1"/>

   <element name="rPr" type="CT_RPr" minOccurs="0" maxOccurs="1"/>

   <element name="tblPr" type="CT_TblPrBase" minOccurs="0" maxOccurs="1"/>

   <element name="trPr" type="CT_TrPr" minOccurs="0" maxOccurs="1"/>

   <element name="tcPr" type="CT_TcPr" minOccurs="0" maxOccurs="1"/>

   <element name="tblStylePr" type="CT_TblStylePr" minOccurs="0" maxOccurs="unbounded"/>

   </sequence>

   <attribute name="type" type="ST_StyleType" use="optional"/>

   <attribute name="styleId" type="ST_String" use="optional"/>

   <attribute name="default" type="ST_OnOff" use="optional"/>

   <attribute name="customStyle" type="ST_OnOff" use="optional"/>

</complexType>