# Style

The `<style>` tag within `<styles>` directly in the body allows you to create style classes you can reuse throughout the document. Each style needs to have an id so you can reference it later.

## Example

```xml
<adx>
  <styles>
    <style
      name='fineprint'
      font='Courier'
      fontSize='9'
    />
    <style
      name='h1'
      fontSize='16'
      color='green'
      spaceBelowLine='20'
    />
    <style
      name='field_content'
      fontSize='16'
      spaceAboveLine='20'
      spaceBelowLine='20'
      titleWidth='100'
    />
  </styles>

  <body>
    <text class="h1" spaceAfter="10">
      Employment Contract
    </text>
    <pageBreak/>
    <text class="fineprint">
      Here goes some legal fineprint
    </text>
    <field
      title="Position"
      type="line_right"
      class="field_content"
      height="5cm"
      spaceBefore="1cm"
      spaceAfter="1cm"
    >
      Chief Technology Officer
    </field>
  </body>
</adx>
```

## Attributes

#### `name`

The identifier of the style class. This is used to reference the style from elements via the `class` attribute (or `titleClass` for fields).

The following preset style names are applied automatically to matching elements and can be overridden:

* `default` — fallback style used when no class is specified
* `h1`, `h2` — default styles for `<h1>` and `<h2>` elements
* `field_title` — default style for the title of `<field>` elements
* `field_content` — default style for the value of `<field>` elements
* `fineprint` — smaller gray text style
* `table` — default style used inside `<table>` cells

#### `font` (optional)

The font family to use, e.g. `Helvetica`, `Courier`. See [Font support](/document-xml-adx/font-support.md).

#### `fontWeight` (optional)

The font weight, e.g. `normal` or `bold`.

#### `fontStyle` (optional)

The font style, e.g. `normal` or `italic`.

#### `fontSize` (optional)

The font size in pt, mm or cm (e.g. `fontSize="12"`).

#### `align` (optional)

Text alignment: `left`, `right`, `center`, or `justify`.

#### `color` (optional)

The text color. Can be a named color (e.g. `red`, `black`) or an RGB value (e.g. `rgb(255, 10, 10)` or `#ff0a0a`).

#### `backgroundColor` (optional)

The background color using the same format as `color`.

#### `spaceBefore` (optional)

Space before the element in pt, mm or cm.

#### `spaceAfter` (optional)

Space after the element in pt, mm or cm.

#### `spaceAboveLine` (optional)

For `<field>` styles that display a line: the space above the line. Default is `0`.

#### `spaceBelowLine` (optional)

For `<field>` styles that display a line: the space below the line. Default is `0`.

#### `titleWidth` (optional)

For `<field>` styles where the title is left of the value: the width of the title in pt, mm or cm.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atfinity.io/document-xml-adx/adx-elements/style.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
