Reference

Style properties

Every CSS property ngpdf reads, with its accepted values, units, defaults and inheritance, plus the properties it ignores and the values that throw.

These are all the style properties ngpdf reads. Any other property is ignored without a warning. An invalid value for a property in this list throws an ngpdf: error and the render rejects.

For a property that takes keywords, a keyword outside its list throws, for every such property, and the message names the value as you wrote it, the property, the element and the keywords it takes:

ngpdf: invalid value "middle" for text-align on pdf-text; use left, center, right or justify

flex-flow and vertical-align follow the same rule. Their messages say what they take, since flex-flow takes up to two keywords and vertical-align also takes a length or a percentage: use baseline, super, sub, a length or a percentage.

A typo or a CSS keyword ngpdf doesn't support, such as break-before: left, font-style: oblique 10deg or vertical-align: middle, fails the render instead of being dropped without a sign.

In the tables:

  • length is a number with an optional unit: none or pt (points), px (= 1pt, whatever the page's dpi), in, cm or mm. Any other unit throws.
  • length/% also accepts a percentage of the parent's content box.
  • color is hex (3, 4, 6 or 8 digits), rgb()/rgba(), a CSS named color or transparent.
  • Keywords are matched in any case, as in CSS: CENTER is center. That covers the keywords of text-align, text-decoration, text-transform, text-overflow, hyphens, vertical-align, white-space, normal in letter-spacing and line-height, display, flex-direction, flex-wrap, flex-flow, justify-content, align-items, align-self, align-content, object-fit, overflow, position, font-weight, font-style, break-before, break-after and break-inside, none in max-lines, none and the function names in transform, the keywords of transform-origin, auto in lengths, auto and none in flex, and the border styles, and the gradient function names and keywords in background and background-image.

Text

All text properties are inherited by child elements.

Property Values Default
color color black
font-family a list of family names: registered fonts and Courier, Times or Helvetica Helvetica
font-size length ≥ 0 10
font-weight a number from 1 to 1000, thin (100), extralight (200), light (300), normal (400), medium (500), semibold (600), bold (700), extrabold (800), black (900), or bolder and lighter from the inherited weight; anything else throws. See Fonts normal (400)
font-style normal, italic, oblique (drawn italic) normal
line-height number (× font size), N%, length, normal (keeps the inherited value) 1.2
text-align left, center, right, justify left
text-decoration none, underline, line-through none
letter-spacing length, negative allowed, or normal (0): space after each character 0
text-transform none, uppercase, lowercase, capitalize none
hyphens manual (break at soft hyphens), none, auto (also where the hyphenation function allows) manual
white-space normal, nowrap, pre, pre-line, pre-wrap: which spaces and line breaks are kept, and whether the text wraps. See White space normal

max-lines, text-overflow and vertical-align are not inherited:

Property Values Default
max-lines integer ≥ 1: the most lines a pdf-text keeps, the last ending in … when text was cut; none none
text-overflow clip, ellipsis: with a fixed height or max-height on the same pdf-text, keep the lines that fit, the last ending in … when text was cut (see Cutting text to its height) clip
vertical-align on a pdf-span only: baseline, super, sub, a length (raises; negative lowers) or N% of the span's line height. See Superscript and subscript baseline

A pdf-span takes display, color, font-family, font-size, font-weight, font-style, text-decoration, letter-spacing, text-transform, hyphens, vertical-align and white-space; line-height, text-align, max-lines and text-overflow come from its pdf-text. See Styled runs.

Without a registered family in the list: font-family contains courier or mono: Courier. Contains times, or serif without sans: Times. Otherwise Helvetica. With one, each character takes the first font in the list that has it. See Text and fonts.

Flexbox

Property Values Default
display flex; none leaves the element and everything in it out of the document; any other value throws flex
flex-direction row, column column; row on pdf-row
flex-wrap nowrap, wrap, wrap-reverse nowrap
flex-flow <direction> || <wrap>: one or two keywords in any order; the part left out goes back to its default
justify-content flex-start, center, flex-end, space-between, space-around, space-evenly flex-start
align-items stretch, flex-start, center, flex-end stretch
align-self auto, stretch, flex-start, center, flex-end auto
align-content stretch, flex-start, center, flex-end, space-between, space-around, space-evenly: where the lines of a wrapping container go in its free cross space stretch
gap <row> [<column>]: one or two lengths/% ≥ 0; one value sets both 0
row-gap length/% ≥ 0: space between the children of a column, or between the lines of a wrapping row; a % is of the container's content height 0
column-gap length/% ≥ 0: space between the children of a row, or between the columns of a wrapping column; a % is of the container's content width 0
flex see below
flex-grow number 0
flex-shrink number 1
flex-basis length/%, auto auto

display is not inherited. It applies to every pdf-* element, pdf-span and pdf-note included, and is ignored on a component host element like its other styles. See Hiding elements.

flex takes:

Value grow shrink basis
auto 1 1 auto
none 0 0 auto
<number> number 1 0
<length> 1 1 length
<number> <number> first second 0
<number> <length> number 1 length
<number> <number> <length> first second length

Size and spacing

Property Values Default
width, height length/%, auto auto
min-width, min-height length/%, auto (no limit) auto
max-width, max-height length/%, auto (no limit) auto
margin 1 to 4 values of length/% or auto 0
margin-top, margin-right, margin-bottom, margin-left length/%, auto 0
padding 1 to 4 values of length/% ≥ 0 0
padding-top, padding-right, padding-bottom, padding-left length/% ≥ 0 0

Shorthands with 1 to 4 values follow CSS order: top, right, bottom, left.

Borders and background

Property Values Default
border <width> <style> <color>, each optional, in any order none
border-top, border-right, border-bottom, border-left same as border, for one side none
border-width 1 to 4 lengths or thin, medium, thick 0
border-top-width, border-right-width, border-bottom-width, border-left-width length or thin, medium, thick 0
border-color 1 to 4 colors black
border-top-color, border-right-color, border-bottom-color, border-left-color color black
border-style 1 to 4 of solid, dashed, dotted, none, hidden (and the styles drawn solid, below) solid
border-top-style, border-right-style, border-bottom-style, border-left-style one style solid
border-radius 1 to 4 lengths, from the top-left corner clockwise 0
border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius length 0
background-color color none
background-image linear-gradient(), radial-gradient() or none; see Gradients none
background a color, a gradient, or one of each in any order; it resets the one it leaves out none
opacity number from 0 to 1 (clamped) 1
transform none, or a list of rotate(), scale(), scaleX(), scaleY(), translate(), translateX(), translateY() none
transform-origin 1 or 2 of left, center, right, top, bottom, length, % of the border box center (50% 50%)
overflow visible; hidden, clip, scroll or auto clip the content to the padding box visible
position static, relative, absolute static
top, right, bottom, left length/%, negative allowed, or auto; a percentage of an absolute element is of its containing block's padding box auto

In border, a missing width is 1 and a missing color is black. The width keywords thin, medium and thick mean 1, 3 and 5 points. border and border-<side> set the style of the sides they cover, and solid when they name none. A side whose style is none or hidden has a width of 0, whichever declaration comes last. dashed draws dashes 3 widths long and dotted round dots one width across, 2 widths apart; see Backgrounds, borders and radius. double, groove, ridge, inset and outset are drawn solid with a dev-mode warning. Unlike CSS, the default style is solid, so border-width: 2 on its own draws a border. border-radius rounds the background and the borders. Radii that add up to more than a side are scaled down together, as in CSS. overflow is not inherited and is ignored on a pdf-page and a pdf-table; see Overflow.

transform applies its functions left to right, around transform-origin, and changes only how the element is drawn, not the layout. Angles take deg, rad or turn, and a positive angle turns clockwise. scale() takes one number for both axes or two. Translations take lengths or a percentage of the element's own border box. Neither property is inherited, and transform is ignored on a pdf-page and a pdf-table. See Transforms.

position and the four offsets are not inherited. The offsets do nothing on a static element. All five are ignored on a pdf-page, a pdf-row and a pdf-cell, where their values are still checked. See Positioning.

Images, pages and breaks

Property Values Default
object-fit contain, cover contain
break-before page starts a new sheet; auto does nothing auto
break-after page starts a new sheet after the element; avoid or avoid-page keeps it on a sheet with what follows; auto does nothing auto
break-inside avoid or avoid-page keeps a pdf-text, a column pdf-view or a pdf-table on one sheet when it fits on one, and keeps a table row or row pdf-view taller than a page from splitting (which views split); auto does nothing auto
min-presence-ahead 0 or a length: when less than this is left on the sheet below the element, it moves to the next sheet; see Leaving room after an element 0
orphans integer ≥ 1: the fewest lines of a pdf-text before a page break (inherited) 2
widows integer ≥ 1: the fewest lines of a pdf-text after a page break (inherited) 2

Ignored

Everything else is ignored, including:

  • z-index, overflow-x, overflow-y;
  • order;
  • box-shadow;
  • font, word-spacing;
  • custom properties (--name).

Some styles are ignored in specific places:

  • on a component host element (with a warning);
  • width, height, the min-/max- sizes and margin on a pdf-page;
  • horizontal padding, left and right borders, margins, justify-content, flex-direction, flex-wrap and the column gap (column-gap, or the column part of gap) on a pdf-row inside a table;
  • margins, min-width and max-width on a pdf-cell inside a table;
  • position and size styles other than height on pdf-page-number;
  • position, top, right, bottom and left on a pdf-page, a pdf-row and a pdf-cell;
  • everything except display and the eleven text properties above on a pdf-span (with a warning);
  • vertical-align on anything but a pdf-span (with a warning).

Throws

  • an unknown unit: em, rem, vh, vw and the like;
  • auto in gap, row-gap or column-gap, or more than two values in gap;
  • a percentage or auto in font-size, border-radius, a border-*-radius corner, border-width or a border's width;
  • an elliptical radius such as border-radius: 4 / 8;
  • auto in padding or a padding-* side;
  • a negative font-size, padding, gap, border width, radius or min-presence-ahead (margins can be negative, as in CSS);
  • a percentage or a keyword such as auto in min-presence-ahead: ngpdf: invalid value "auto" for min-presence-ahead on pdf-text; use 0 or a length;
  • a color that is not one of the forms above, including hsl(), currentColor and var();
  • a keyword outside the lists above for any keyword property: font-weight, font-style, text-align, text-decoration, text-transform, text-overflow, hyphens, white-space, display, flex-direction, flex-wrap, flex-flow, justify-content, align-items, align-self, align-content, border-style and its sides, object-fit, overflow, position, break-before, break-after and break-inside, in any case, and for vertical-align on a pdf-span (middle, top and the like);
  • position: fixed and position: sticky;
  • a transform function other than the seven above, such as skew(), matrix() or rotate3d(), an angle without a unit (other than 0) and a transform-origin with three values;
  • a value that is not a number for flex-grow, flex-shrink and opacity;
  • the wrong number of values in a shorthand;
  • in background or background-image: repeating-* gradients, conic-gradient(), url(), several comma-separated backgrounds, explicit radial sizes, color hints, a stop with two positions, fewer than two stops, and anything else that is not a color or a supported gradient.