In ODF all formatting lives in styles; the text only names them. Common styles (the
ones a user sees, such as “Heading 1”) are in office:styles in
styles.xml; automatic styles, made by the program for formatting applied
directly to a piece of text, are in office:automatic-styles in
content.xml or styles.xml; master pages are in
office:master-styles (see document
structure). A reference to a style or font face should point to one defined in the
same file or in styles.xml. This page covers chapter 16 of OpenDocument
1.3 part 3; the formatting properties a style holds are on the
text,
paragraph,
page and section,
table and
graphic formatting
pages.
style:style
A style has a family and a name; the pair must be unique within each of
office:styles, office:automatic-styles and
office:master-styles. Its children are property elements
(style:text-properties, style:paragraph-properties and so
on, depending on the family) and style:map conditions.
| Attribute | Values | Meaning |
|---|---|---|
style:name | name | The style’s name. Producers make up names for automatic styles; they may differ each time the document is saved, and should not clash with names in the other files. |
style:family | see Families | What the style applies to. |
style:display-name | text | The name shown to users; if missing, style:name. |
style:parent-style-name | name | The style it inherits from. Must exist and must not be an automatic style. Without it, the family’s default style is the parent. |
style:next-style-name | name | Paragraph styles: the style for the next paragraph when the user presses Enter (default: the same style). |
style:class | text | A free class name, for grouping styles in a user interface; no meaning in the format. |
style:auto-update | false (default), true | true: a formatting change made to an object updates the common style itself, so every object using it changes; false: the change is made to that object only, with a new automatic style if needed. |
style:master-page-name | master page name | Paragraph and table styles: applying the style inserts a page break before the paragraph or table, and the new page uses that master page. Ignored for paragraphs inside tables. |
style:list-style-name | list style name or empty | Paragraph styles: the list style for headings and paragraphs in a list that has no list style of its own or from any parent list. Empty stops inheritance from the parent style. |
style:list-level | positive integer or empty | A list level a program may give the paragraph when the style is applied; only with a non-empty style:list-style-name on a paragraph style. |
style:default-outline-level | positive integer or empty | Paragraph styles: when a user applies the style, the program should turn the paragraph into a heading of this level. It does not change how existing text:p and text:h are read. |
style:data-style-name | data style name | Table-cell and chart styles: the number, date or other data style for values. |
style:percentage-data-style-name | data style name | Chart styles: a percentage data style for data labels shown as percentages. |
Families
style:family | Applied to | Property elements it may hold |
|---|---|---|
text | Spans and other runs of characters. | text |
paragraph | Paragraphs and headings. Its text properties apply to the paragraph’s characters unless a text style inside overrides them. | paragraph, text |
section | Sections and indexes. | section |
ruby | Ruby annotations. | ruby |
table | Tables. | table |
table-column | Table columns. | table-column |
table-row | Table rows. | table-row |
table-cell | Table cells. Its paragraph and text properties apply to paragraphs in the cell unless their own style overrides them. | table-cell, paragraph, text |
graphic | Frames and drawing shapes; paragraph and text properties apply to text in them. | graphic, paragraph, text |
presentation | Presentation objects (in presentations). | graphic, paragraph, text |
drawing-page | Drawing pages: a background that overrides the master page’s (but not the master page’s shapes); in presentations also transitions and other presentation properties. | drawing-page |
chart | Parts of charts. A data point without a value takes it from its series, then the plot area. | chart, graphic, paragraph, text |
Finding a property’s value
A reader works out each formatting property for an element like this:
- Look in the style the element names. If the property is there, use it.
- Otherwise look in its parent style, then the parent’s parent, until a style with no parent.
- Then follow the family rule:
- a text style inside another element with a text style: continue in the nearest enclosing text style and its parents;
- a text style inside a paragraph: continue in the paragraph’s style and its parents;
- a paragraph style in a shape or chart: continue in the shape’s graphic, presentation or chart style;
- a paragraph style in a table cell: continue in the cell style, then as for cells;
- a cell style: continue with the row’s
table:default-cell-style-name, then the column’s.
- Then the default style (
style:default-style) of the family the search began with. - Then the default value the specification gives, if any; otherwise the value is up to the program.
style:default-style has only style:family and the same
property elements as style:style. A document should contain a default
style for every family it uses.
<office:styles>
<style:default-style style:family="paragraph">
<style:text-properties fo:font-size="12pt" fo:language="en" fo:country="GB"/>
</style:default-style>
<style:style style:name="Standard" style:family="paragraph" style:class="text"/>
<style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph"
style:parent-style-name="Standard" style:next-style-name="Standard" style:default-outline-level="1">
<style:text-properties fo:font-size="16pt" fo:font-weight="bold"/>
</style:style>
</office:styles>
Conditional styles
A style:map inside a style makes it conditional: when its condition is
true, the style named by style:apply-style-name is used instead. That
style must be a common style of the same kind and family. Paragraph styles in text
documents, cell styles in spreadsheets and data styles may be conditional.
style:condition is a namespace prefix, a colon and a condition; with no
prefix it is OpenFormula. A reader ignores a map whose condition it does not know.
style:base-cell-address (an absolute address with table name) is the
base for relative addresses in a cell-style condition.
| Used by | Conditions |
|---|---|
| Paragraph styles | footnote(), endnote() (in a footnote or endnote); header(), footer() (in a page header or footer); list-level()=n (in a list, or a numbered paragraph, at level n); outline-level()=n (a heading of level n); section() (in a section); table(), table-header() (in a table cell or header cell). n is a positive integer. |
| Table cell styles | cell-content() op value with op <, >, <=, >=, =, !=; cell-content-is-between(v1, v2); cell-content-is-not-between(v1, v2); is-true-formula(expression). A value is a decimal number, a string in double quotes (a quote inside doubled), or an expression. |
| Data styles | value() op n, with the same operators; n is a number, or true/false for Boolean styles. |
Page layouts and master pages
A page layout (style:page-layout, in automatic styles) holds the page
size, margins and so on in style:page-layout-properties, and the header
and footer formatting in style:header-style and
style:footer-style (each holding
style:header-footer-properties). style:default-page-layout
has the same children and no attributes. A master page
(style:master-page) uses a page layout and holds the header and footer
text. Every document must have at least one master page.
Pages are made from master pages as the text flows: each new page is an empty page with the master page’s properties and fixed content, then filled with body text. Headers and footers are part of the page style, unlike XSL, where they belong to the page sequence.
| Element or attribute | Meaning |
|---|---|
style:page-layout style:name | The layout’s name. |
style:page-usage | all (default) or mirrored: the same header and footer on left and right pages unless left versions are given; left: only left pages, right-page headers and footers ignored; right: only right pages, style:header-left and style:footer-left ignored. |
style:master-page | Attributes style:name (unique), style:display-name, style:page-layout-name, style:next-style-name (master page for the next page when this one is full; default itself), draw:style-name (a drawing-page style, for drawings and presentations). Children: headers and footers, forms, shapes and frames, and in presentations notes, layers and animations. |
style:header, style:footer | Header and footer content. |
style:header-left, style:footer-left | Content for left pages, if different. |
style:header-first, style:footer-first | Content for the first page the page style is applied to (regardless of numbering), if different. Each separate run of the page style has its own first page. |
style:display | On each header and footer element: true (default) or false (hidden). |
style:region-left, style:region-center, style:region-right | A header or footer may be split into left-aligned, centred and right-aligned regions, each holding paragraphs (used by spreadsheets). |
A header or footer holds the same kinds of content as the body: paragraphs, headings, lists, tables, sections, indexes, tracked changes, and variable, sequence, user-field and DDE declarations.
<office:automatic-styles>
<style:page-layout style:name="pm1">
<style:page-layout-properties fo:page-width="21cm" fo:page-height="29.7cm"
style:print-orientation="portrait" fo:margin="2cm"/>
<style:header-style/>
<style:footer-style><style:header-footer-properties fo:min-height="0cm"/></style:footer-style>
</style:page-layout>
</office:automatic-styles>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1">
<style:footer><text:p><text:page-number text:select-page="current"/></text:p></style:footer>
</style:master-page>
</office:master-styles>
Table templates
A table:table-template (named by table:name) names cell
styles by position, for building tables. Each child has table:style-name
(a table-cell style) and table:paragraph-style-name (for the
empty paragraphs put in new cells). When several apply to a cell, the first in this
order wins:
table:first-columntable:last-columntable:first-rowtable:last-rowtable:even-rows,table:odd-rows(banded rows)table:even-columns,table:odd-columns(banded columns)table:body(everything else)
table:background names a table style that shows through
transparent parts. A table uses a template through table:template-name
and the table:use-…-styles switches (see
Tables). The old
attributes table:first-row-start-column,
table:first-row-end-column, table:last-row-start-column
and table:last-row-end-column (row or column:
whether that corner cell takes the row’s or the column’s style) are deprecated.
Font faces
Fonts are declared in office:font-face-decls, one
style:font-face each. A declaration matches a CSS2 @font-face
and an SVG font-face. Text properties pick one by name with
style:font-name; a font chosen by name is used directly, without CSS
font matching.
| Attribute | Values | Meaning |
|---|---|---|
style:name | name | The name text properties use. |
svg:font-family | text | The font family. |
style:font-family-generic | roman, swiss, modern, decorative, script, system | Generic family: serif, sans-serif, modern, decorative, script, system. |
style:font-pitch | fixed, variable | Fixed or variable width. |
style:font-charset | x-symbol or an encoding name | x-symbol: the font does not follow Unicode (it may use the private use area); a Unicode encoding: it does. Other values are deprecated. |
style:font-adornments | text | A style name such as bold or italic that, with the family, picks the font. |
svg:font-style, svg:font-variant, svg:font-weight, svg:font-stretch, svg:font-size, svg:unicode-range, svg:units-per-em, svg:panose-1, svg:stemv, svg:stemh, svg:slope, svg:cap-height, svg:x-height, svg:accent-height, svg:ascent, svg:descent, svg:widths, svg:bbox, svg:ideographic, svg:alphabetic, svg:mathematical, svg:hanging, svg:v-ideographic, svg:v-alphabetic, svg:v-mathematical, svg:v-hanging, svg:underline-position, svg:underline-thickness, svg:strikethrough-position, svg:strikethrough-thickness, svg:overline-position, svg:overline-thickness | as SVG 1.1 §20.8.3 | The SVG font descriptors. |
Children, as in SVG: svg:font-face-src holding
svg:font-face-uri (an xlink:href to a font file, with
svg:font-face-format and its svg:string) and
svg:font-face-name (svg:name, a locally installed font); and
svg:definition-src (xlink:href).
Data styles
Data styles say how a number, date, time, Boolean or text value is shown. A cell
style or a field names one. A data style may not have two number:text
elements in a row, and may have at most one number:fill-character.
| Element | For | Children |
|---|---|---|
number:number-style | Numbers. | number:number, number:scientific-number or number:fraction; number:text, number:fill-character, style:text-properties, style:map |
number:currency-style | Currency amounts. | number:number, number:currency-symbol, text, fill, text properties, maps |
number:percentage-style | Percentages; should have a number:text containing %. | number:number, text, fill, text properties, maps |
number:date-style | Dates (and times). | number:day, number:month, number:year, number:era, number:day-of-week, number:week-of-year, number:quarter, number:hours, number:minutes, number:seconds, number:am-pm, text, fill, text properties, maps |
number:time-style | Times and durations; at most one each of hours, minutes, seconds and am-pm. | number:hours, number:minutes, number:seconds, number:am-pm, text, fill, text properties, maps |
number:boolean-style | Boolean values. | number:boolean (where the value goes), text, text properties, maps |
number:text-style | Text values. | number:text-content (where the text goes), text, fill, text properties, maps |
Every data style element takes style:name, style:display-name,
number:title, style:volatile (true: keep it even
if unused; false: it may be discarded), the locale attributes
number:language, number:country, number:script
and number:rfc-language-tag (an RFC 5646 tag, only when the other three
cannot express it), and the digit transliteration attributes
number:transliteration-format (a digit one character naming the digit
set, default 1; with none, ASCII digits and the other transliteration
attributes are ignored), number:transliteration-language,
number:transliteration-country and
number:transliteration-style (short (default),
medium, long; meaning up to the locale and program). Date and
currency styles also take number:automatic-order (default
false; true: put the parts in the locale’s usual order);
date and time styles take number:format-source; time styles take
number:truncate-on-overflow.
| Element or attribute | Values | Meaning |
|---|---|---|
number:number | – | A decimal number. May contain number:embedded-text. |
number:decimal-places | integer | Decimal places shown; if missing, the default cell style’s. On number:seconds: decimals of seconds (default 0). |
number:min-decimal-places | integer, not above decimal-places | Decimals always shown; trailing zeros after this are dropped. Default on number:number: 0 if number:decimal-replacement is empty, otherwise decimal-places; on scientific numbers, decimal-places. |
number:decimal-replacement | text | Shown in place of the decimals when the number is whole (what is supported is up to the program). |
number:min-integer-digits | integer | Minimum digits before the point. On a fraction with none, no whole part is shown. |
number:grouping | false (default), true | Group thousands with the locale’s separator. |
number:display-factor | number, default 1 | The number is divided by this before display. |
number:embedded-text number:position | integer from 1 | Fixed text inserted before the digit at that position, counted from the right of the integer part. |
number:scientific-number | – | Scientific notation: decimal-places, min-decimal-places, min-integer-digits, grouping, and number:min-exponent-digits, number:exponent-interval (exponents are multiples of this, default 1), number:forced-exponent-sign (default true: always show the exponent’s sign). |
number:fraction | – | A fraction: number:min-integer-digits, number:grouping, number:min-numerator-digits, number:min-denominator-digits, number:denominator-value (fixed denominator; if missing a suitable one is chosen), number:max-denominator-value (largest allowed denominator, ignored with a fixed one; 99 means any one- or two-digit denominator). |
number:currency-symbol | text | The currency symbol; empty or white space means the default for the style’s or the element’s own language and country. |
number:text | text | Fixed text. |
number:fill-character | a character | Repeated to fill the cell width (the rest of the space is distributed as the program chooses). |
number:style | short, long | With number:format-source="fixed" (the default): day, hours, minutes and seconds short = at least one digit, long = two; month short = abbreviated name or one or two digits, long = full name or two digits; year short = two digits, long = four; day of week, era and quarter short = abbreviated, long = full name. With language, short and long follow the style’s locale. |
number:textual | false (default), true | Month as a name rather than a number. |
number:possessive-form | false, true | Month name in the possessive (genitive) form rather than nominative; only with textual months. |
number:calendar | gregorian, gengou, ROC, hanja, hanja_yoil, hijri, jewish, buddhist, or another name | Calendar for that part of the date: Gregorian (Julian before 1582-10-15); Japanese emperor eras (readers may support only Meiji onwards); Taiwanese Minguo (year minus 1911); Korean names for a Gregorian date (hanja_yoil is an old alias); Islamic Hijri; Jewish; Buddhist (year plus 543). Missing: the locale’s calendar. |
number:am-pm | – | Show AM or PM; hours are then 1 to 12. |
number:truncate-on-overflow | true (default), false | Whether the largest time part wraps (hours modulo 24, minutes and seconds modulo 60) or may grow beyond 23 or 59, as for durations. |
<number:date-style style:name="N37" number:automatic-order="true">
<number:day number:style="long"/><number:text>/</number:text>
<number:month number:style="long"/><number:text>/</number:text>
<number:year number:style="long"/>
</number:date-style>
List and outline styles
A text:list-style (style:name,
style:display-name, text:consecutive-numbering: default
false, each level restarts its numbering; true: one count
across all levels) holds one level style per level. A level with no level style uses
the one for the next lower level, or the program’s default. A list style placed inside
a graphic style works as if the graphic style had style:list-style-name
pointing to it; its name is not shown to users.
| Element | Label | Attributes |
|---|---|---|
text:list-level-style-number | A number. | text:level, style:num-format, style:num-letter-sync, style:num-prefix, style:num-suffix, text:display-levels (how many levels’ numbers to show, as in 1.2.3; default 1), text:start-value (default 1), text:style-name (a text style for the number) |
text:list-level-style-bullet | A bullet character. | text:level, text:bullet-char, text:bullet-relative-size (percentage of the paragraph’s font size), style:num-prefix, style:num-suffix, text:style-name |
text:list-level-style-image | An image. | text:level, xlink:href (xlink:show="embed", xlink:actuate="onLoad") or child office:binary-data |
Each level style holds style:list-level-properties (indents and label
position, see paragraph
formatting) and, for number and bullet levels, style:text-properties.
style:num-format is 1 (1, 2, 3), a (a, b, c),
A, i (i, ii, iii), I, another string, or empty
(no number). style:num-letter-sync: false counts a…z, aa,
bb…zz, aaa; true counts a…z, aa, ab…az, ba. Prefix and suffix are text
put before and after the number or bullet; if they contain no letters or digits, prefix
+ format + suffix forms an XSLT format string.
Typical text:bullet-char values given by the standard: U+2022 •
BULLET, U+25CF ● BLACK CIRCLE, U+2714 ✔ HEAVY CHECK MARK, U+2717 ✗ BALLOT X, U+2794 ➔
HEAVY WIDE-HEADED RIGHTWARDS ARROW, U+27A2 ➢ THREE-D TOP-LIGHTED RIGHTWARDS
ARROWHEAD. Not every font has them.
The text:outline-style (only style:name) is the list style
for all headings whose paragraph style has no list style. It holds
text:outline-level-style elements, which take the same attributes and
children as text:list-level-style-number.
Notes, line numbering and bibliography settings
| Element | Attributes and values |
|---|---|
text:notes-configuration (one per note class; without one the program’s defaults apply) | text:note-class = footnote or endnote; style:num-format, style:num-letter-sync, style:num-prefix, style:num-suffix; text:start-value (default 1); text:start-numbering-at = document, chapter or page (where numbering restarts); text:footnotes-position = text (on the page, just below the text), page (bottom of the page), section (end of section), document (end of document); text:citation-style-name (text style of the number in the note), text:citation-body-style-name (text style of the number in the text), text:default-style-name (paragraph style for new notes), text:master-page-name (master page for pages of endnotes). Children text:note-continuation-notice-forward (text at the end of a note continued on the next page) and text:note-continuation-notice-backward (text before the continuation). |
text:linenumbering-configuration | text:number-lines (default true); text:increment (number every nth line); text:number-position = left (default), right, inner, outer; text:offset (distance from the margin); text:count-empty-lines (default true); text:count-in-text-boxes (default false); text:restart-on-page (default false); style:num-format, style:num-letter-sync; text:style-name (text style). Child text:linenumbering-separator: text shown instead of the number on lines not numbered, every text:increment lines. |
text:bibliography-configuration | text:prefix, text:suffix (around a citation in the text); text:numbered-entries (default false: show short names; true: numbers); text:sort-by-position (default true; the standard defines false as document order and true as sorted by the sort keys, the reverse of what the name suggests); fo:language, fo:country, fo:script, style:rfc-language-tag, text:sort-algorithm (collation). Children text:sort-key: text:key (one of the 32 bibliography fields: address, annote, author, bibliography-type, booktitle, chapter, custom1–custom5, edition, editor, howpublished, identifier, institution, isbn, issn, journal, month, note, number, organizations, pages, publisher, report-type, school, series, title, url, volume, year) and text:sort-ascending (default true). |
Gradients, hatches, images, markers and dashes
Graphic styles name these by draw:name; each also has
draw:display-name. They are kept in office:styles; fill
images, opacity gradients, markers and dash styles cannot be automatic styles.
| Element | Attributes and values |
|---|---|
draw:gradient | draw:style = linear (colours blend along an axis at draw:angle, clockwise from vertical), axial (linear, mirrored about its axis), radial (circle round draw:cx, draw:cy), ellipsoid, square (“box” or “pyramid” gradient), rectangular (the standard’s description calls it rectangle); draw:start-color, draw:end-color; draw:start-intensity, draw:end-intensity (0% to 100%, default 100%); draw:border (percentage of the area filled with solid start colour, or end colour for axial); draw:angle (ignored for radial). Outside the shape of a radial, ellipsoid, square or rectangular gradient the end colour is used. |
svg:linearGradient, svg:radialGradient | SVG gradients, with limits: they must have draw:name; only svg:gradientTransform, svg:x1, svg:y1, svg:x2, svg:y2 (linear) or svg:cx, svg:cy, svg:r (default 50%), svg:fx, svg:fy (radial), and svg:spreadMethod (pad (default), reflect, repeat) are used; svg:gradientUnits is always objectBoundingBox; children svg:stop with only svg:offset, svg:stop-color and svg:stop-opacity. They cannot be used as opacity gradients. |
draw:hatch | draw:style = single (parallel lines), double (and perpendicular lines), triple (and lines at 45° clockwise); draw:color; draw:distance (between lines); draw:rotation (clockwise from vertical). |
draw:fill-image | xlink:href (or office:binary-data, only in a flat XML file, not a package); svg:width, svg:height (an estimate; the image’s own size wins). |
draw:opacity | A transparency gradient: draw:style (as for gradients), draw:start, draw:end (0% transparent to 100% opaque), draw:angle, draw:border, draw:cx, draw:cy. |
draw:marker | An arrowhead or other end mark: svg:viewBox and svg:d (the shape, pointing up). It is scaled to the line’s marker width keeping its proportions, centred, placed at offset 0.5 if the style’s draw:marker-start-center or -end-center is true and 0.3 if false (default), rotated to the line’s direction, and drawn at the line’s end. |
draw:stroke-dash | draw:style = rect or round (used only if the style has no svg:stroke-linecap); draw:dots1, draw:dots1-length, draw:dots2, draw:dots2-length (two runs of dashes and their lengths), draw:distance (gap). Lengths may be percentages of the line width. |
Source
OpenDocument Version 1.3, OASIS Standard, 27 April 2021, part 3 (schema), chapter 16
and the style:, number:, text:,
draw: and svg: attributes it references in chapter 19; read
in full for this page. Presentation page layouts and placeholders (16.43, 16.44) and
notes pages (16.19) are described on the ODP
pages.