Styles
How styling works in OOXML - style definitions, inheritance, and direct formatting.
OOXML uses a style system similar to CSS but with its own inheritance rules and quirks.
Style Types
| Type | Element | Description |
|---|---|---|
| Paragraph | w:style w:type="paragraph" | Applied to entire paragraphs |
| Character | w:style w:type="character" | Applied to runs within paragraphs |
| Table | w:style w:type="table" | Applied to tables |
| Numbering | w:style w:type="numbering" | List formatting |
Style Hierarchy
Formatting is resolved in this order (later wins): 1) Document defaults, 2) Style definition, 3) Direct formatting.
Style inheritance is complex
Paragraph styles can be w:basedOn other styles. Character styles can be linked to paragraph styles via w:link. Direct formatting always wins.
Example Style Definition
<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:pPr>
<w:spacing w:before="480" w:after="120"/>
</w:pPr>
<w:rPr>
<w:b/>
<w:sz w:val="48"/>
</w:rPr>
</w:style>