Borders, background and box
These fields frame, shade and pad paragraphs, tables, table cells and images. None of them inherit: a border on the Document is not passed to every paragraph.
Legend: ✓ supported; ✗ ignored with a warning; — ignored silently.
Borders
Section titled “Borders”| Field | Example | Meaning | docx | html | |
|---|---|---|---|---|---|
border |
"0.5pt solid #CCCCCC" |
All four sides | ✓ | ✓ | ✓ |
borderTop borderRight borderBottom borderLeft |
"3pt solid #D4A72C" |
One side, overrides border |
✓ | ✓ | ✓ |
borderBetween |
"0.5pt solid #EEEEEE" |
Line between adjacent paragraphs of the same style | ✓ | ✗ | ✗ |
borderInsideH |
"none" |
Inner horizontal table lines; defaults to border |
✓ | ✓ | ✓ |
borderInsideV |
"none" |
Inner vertical table lines; defaults to border |
✓ | ✓ | ✓ |
borderDiagonal |
Diagonal cell line | not implemented | not implemented | not implemented |
How to write one side (string, object, "none") and the line styles: Values.
Background
Section titled “Background”| Field | Example | Meaning | docx | html | |
|---|---|---|---|---|---|
background |
"#F5F7FA" |
Solid color, pattern or gradient | ✓ gradient uses first color | ✓ pattern blended to solid | ✓ pattern blended to solid |
In a run’s style it shades only that bit of text.
| Field | Example | Meaning | docx | html | |
|---|---|---|---|---|---|
padding |
8 |
Padding on all sides | paragraphs only when bordered; table cells ✓ | ✓ | ✓ |
paddingTop paddingRight paddingBottom paddingLeft |
2 |
One side, overrides padding |
same | ✓ | ✓ |
width |
"80%", "120mm" |
Width; percentages are of the text width | tables, images | ✓ | ✓ |
height |
"40mm" |
Height | images | ✓ | ✓ |
verticalAlign |
"middle" |
Vertical alignment: top middle bottom |
table cells, absolutely positioned images | same | same |
textRotation |
90 |
Text direction: 0 90 270 |
table cells | ✓ | ✓ |
radius |
4 |
Corner radius | ✗ | ✓ | ✓ |
On text, verticalAlign means super/subscript (super sub); on cells and images it means vertical alignment.
Paragraph borders in docx
Section titled “Paragraph borders in docx”Word paragraphs have no real box, so fmtagno does this:
- Paragraph borders become Word paragraph borders.
paddingbecomes the gap between border and text, so it only works when there is a border. Background without a border ignorespadding, with a warning.- For a shaded, padded callout, add a border in the same color as the background.
Example
Section titled “Example”"styles": { "note": { "background": "#FFF8C5", "borderLeft": "3pt solid #D4A72C", "padding": 8 }, "card": { "border": "0.5pt solid #D0D7DE", "radius": 6, "padding": 10, "background": { "gradient": "linear", "angle": 90, "stops": ["#FFFFFF", "#E8F0FE"] } }}