Supported CSS
Supported CSS attributes - stylesheets or in-line
Unless otherwise stated, the following values are supported:
- LENGTH
-
px
,pc
,pt
,cm
,mm
,in
,em
,rem
,ex
and%
(where appropriate) are supported. Default if no unit given ispx
. - FONT-SIZE
-
px
,pc
,pt
,em
,rem
,ex
,%
,small
,medium
,large
,x-small
,x-large
are supported. Default if no unit given ispx
.Note: Support for
rem
was added in mPDF 5.7. Unlike the CSS3 specification, the basic size used forrem
in the document is based on thefont-size
set on the<body>
element (rather than the<html>
element).Conversion from
px
is determined by the configurable variablesdpi
andimg_dpi
ex
uses an approximation of half the font height - FONT-FAMILY
-
Any font family defined in your configuration, as well as
sans
,sans-serif
,serif
ormonospace
. - ALPHA
-
transparency, value between
0
and1
- COLOR
-
#rgb
or#rrggbb
orrgb(255,255,255)
or colour names e.g.black
,gray
are supported.Also supported are:
rgb(255, 255, 255)
rgba(255, 255, 255, 1)
last value is ALPHA *rgb(100%, 100%, 100%)
hsl(360, 100%, 100%)
hsla(360, 100%, 100%, 1)
last value is ALPHA *cmyk(100, 100, 100, 100)
[or 0-100%]cmyka(100, 100, 100, 100, 1)
[or 0-100%] last value is ALPHA *device-cmyk(100, 100, 100, 100)
[or 0-100%]device-cmyka(100, 100, 100, 100, 1)
last value is ALPHA *spot(<color name>, 100%)
. (cf. AddSpotColor)
since mPDF 5.7, spotcolor CMYK values can be defined as it is used e.g.
color: spot(PANTONE 534 EC, 100%, 85, 65, 47, 9);
* Alpha values (transparency) are only supported on background colours - not text color
- GRADIENT
-
Both the Mozilla or the draft CSS3 syntax are supported e.g.:
background: -moz-repeating-linear-gradient(red, blue 20px, red 40px)
background-image: -moz-repeating-linear-gradient(red, blue 20px, red 40px)
background: linear-gradient(top, #c7cdde, #f0f2ff);
background-image: linear-gradient(top, #c7cdde, #f0f2ff);
There are more values supported. (cf. Backgrounds & borders)
- GRADIENT_OLD
-
background-gradient: GRADIENT_OLD
is deprecatedDefines a linear or radial colour gradient for the background.
linear
COLOR1x1 y1 x2 y2;
orradial
COLOR1x1 y1 x2 y2 radius;
x
,y
andradius
are values between0
and1
(custom attribute) (cf. Backgrounds & borders)
HTML Tag | Property | Values allowed & Notes |
---|---|---|
BODY | direction | rtl | ltr (mPDF ≥ 5.0) |
COMMON TEXT STYLES | See below - all except text-shadow | |
margin-collapse |
collapse|none (custom attribute - collapses top and bottom margins if at top or bottom of page) | |
line-height |
Line height as a factor of font-height. Usual values around 1.2 or 1.3 Also accepts |
|
background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (cf. Backgrounds & borders) (All except background-color added mPDF 3.0) |
|
background-image-resolution |
normal | [ from-image <dpi> ] (mPDF ≥ 5.1) Custom tag, but as for image-resolution in CSS3 |
|
background-gradient |
(Deprecated) GRADIENT_OLD | |
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
background-image-resize |
0 - No resizing (default) 1 - Shrink-to-fit w (keep aspect ratio) 2 - Shrink-to-fit h (keep aspect ratio) 3 - Shrink-to-fit w and/or h (keep aspect ratio) 4 - Resize-to-fit w (keep aspect ratio) 5 - Resize-to-fit h (keep aspect ratio) 6 - Resize-to-fit w and h |
|
All Block level tags: P, DIV, H1-H6, OL, UL, ADDRESS, BLOCKQUOTE, CAPTION, CENTER, DL, DT, DD, FORM, ARTICLE, ASIDE, DETAILS, FIELDSET, FIGURE, FIGCAPTION, FOOTER, HEADER, HGROUP, NAV, SECTION, SUMMARY | margin*, margin-top, margin-bottom, margin-left, margin-right | LENGTH |
padding*, padding-right, padding-left, padding-top, padding-bottom | LENGTH | |
border, border-top, border-bottom, border-left, border-right |
Size style and colour e.g. LENGTH solid|dotted|dashed|double COLOR |
|
border-color*, border-top-color, border-right-color, border-bottom-color, border-left-color |
COLOR (mPDF ≥ 4.0) |
|
border-width*, border-top-width, border-right-width, border-bottom-width, border-left-width |
LENGTH (mPDF ≥ 4.0) |
|
border-style*, border-top-style, border-right-style, border-bottom-style, border-left-style |
solid | dotted | dashed | double (mPDF ≥ 4.0) (double was added mPDF 4.2) |
|
border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius |
LENGTH See draft CSS3 specification for use. NB Use of |
|
width |
LENGTH mPDF does not support nested block elements which overlap (horizontally or vertically) i.e. the inner block must be contained by the outer block’s physical dimensions. width and height are overridden if this is not the case. |
|
height |
LENGTH mPDF does not support nested block elements which overlap (horizontally or vertically) i.e. the inner block must be contained by the outer block’s physical dimensions. width and height are overridden if this is not the case. (Prior to mPDF v5.1: only supported if whole block is all on one page; will extend a block but not shorten it; will not force a pagebreak even if height should move onto next page.) NB % is interpreted as % of printable page height (inside margins) |
|
text-align | left | center | right | justify | |
page-break-after | auto | avoid | always | left | right (extended mPDF ≥ 5.4) | |
page-break-inside | avoid (avoids a page-break within the block - only works across max. of 2 pages; not compatible with table autosize or table rotate) | |
page-break-before | always | left | right | |
display | none | |
visibility |
visible | hidden | printonly | screenonly (mPDF ≥ 5.4) |
|
margin-collapse |
collapse | none (custom attribute - collapses top and bottom margins if at top or bottom of page) | |
line-height |
Line height as a factor of font-height. Usual values around 1.2 or 1.3 Also accepts px, pc, pt, cm, mm, in, em and % (mPDF ≥ 4.0) ‘normal’ also accepted (set by default to 1.3 in mPDF) |
|
line-stacking-strategy |
inline-line-height | block-line-height | max-height | grid-height As per draft CSS3 spec. (mPDF ≥ 6.0) Default = inline-line-height |
|
line-stacking-shift |
consider-shifts | disregard-shifts As per draft CSS3 spec. (mPDF ≥ 6.0) Default = consider-shifts |
|
background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (cf. Backgrounds & borders) (All except background-color added mPDF 3.0) |
|
background-clip |
padding-box | border-box (default=border-box) extended to include “content-box” from mPDF 5.7 |
|
background-origin |
padding-box | content-box | border-box (default padding-box) As per CSS3. mPDF ≥ 5.7 |
|
background-size |
[ <length> | <percentage> | auto ]{1,2} | cover | contain (default = auto) As per CSS3. mPDF ≥ 5.7 |
|
background-image-resolution |
normal | [ from-image <dpi> ] (mPDF ≥ 5.1) Custom tag, but as for image-resolution in CSS3 |
|
background-gradient |
(Deprecated) GRADIENT_OLD | |
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
background-image-resize |
0 - No resizing (default) 1 - Shrink-to-fit w (keep aspect ratio) 2 - Shrink-to-fit h (keep aspect ratio) 3 - Shrink-to-fit w and/or h (keep aspect ratio) 4 - Resize-to-fit w (keep aspect ratio) 5 - Resize-to-fit h (keep aspect ratio) 6 - Resize-to-fit w and h |
|
box-shadow |
As per CSS3 specification. ‘inset’ is not supported. (mPDF ≥ 5.4) |
|
box-decoration-break |
slice | clone (default = slice) Defines the handling of padding and borders at page breaks, when clonebycss set |
|
z-index |
Sets a layer in the PDF document. Note: this is not the same as a “layer” in CSS terms. See Layers. |
|
All Block level tags: P, DIV, H1-H6, OL, UL, ADDRESS, BLOCKQUOTE, CAPTION, CENTER, DL, DT, DD, FORM, ARTICLE, ASIDE, DETAILS, FIELDSET, FIGURE, FIGCAPTION, FOOTER, HEADER, HGROUP, NAV, SECTION, SUMMARY (contd.) | COMMON TEXT STYLES | See below |
text-indent |
Indents first line of text in the paragraph/block. LENGTH (Indent is disabled in tables.) Negative value will give a ‘hanging indent’. |
|
position |
fixed | absolute absolute - uses physical page as containing element; fixed - uses printable page (inside margins) as containing element. (mPDF ≥ 4.0) NB Only supported for top-level elements i.e. where the parent element is <body>. Fixed-position or floating elements nested inside other fixed-position or floating elements are not supported. |
|
overflow |
visible | hidden | auto Applies to block elements with position fixed or absolute. auto - causes text to autofit within the block size (constrained if necessary to page edges). (mPDF ≥ 4.0) |
|
hyphens |
none | manual | auto (default = manual) As per CSS. (mPDF ≥ 5.7) |
|
rotate |
90 | -90 Applies only to block elements with position fixed or absolute. (mPDF ≥ 5.0) Sizing and layout of the block element using top, left, bottom, right, width and height are applied BEFORE the element is rotated. The top and left co-ordinates are respected for positioning, except when bottom or right are specified without respective top or left when the bottom/right co-ordinates are used. |
|
top, left, bottom, right |
LENGTH Applies to block elements with position fixed or absolute. (mPDF ≥ 4.0) |
|
float |
left | right Partially supported as for CSS2 property. NB Fixed-position or floating elements nested inside other fixed-position or floating elements are not supported. |
|
clear | left | right | both | |
page | Specify a named page selector (see @page) | |
direction | rtl | ltr (mPDF ≥ 5.1) |
HTML Tag | Property | Values allowed & Notes |
---|---|---|
LIST tags: OL, UL | list-style | [ 'list-style-type' 'list-style-position' 'list-style-image' ] mPDF ≥ 6.0 |
list-style-type* * |
1 | A | a | I | i | disc | circle | square | decimal | lower-roman | upper-roman | lower-latin | upper-latin | lower-alpha | upper-alpha | none arabic-indic | bengali | cambodian | cjk-decimal | devanagari | gujarati | gurmukhi | hebrew |kannada | khmer | lao | malayalam | oriya | persian | telugu | thai | urdu | tamil “1” - decimal “A” = upper-latin “a” = lower-latin “I” = upper-roman “i” = lower-roman Custom list-style-type is recognised e.g.:
|
|
list-style-image |
<URI> mPDF ≥ 6.0 |
|
list-style-position |
inside | outside (default = outside) mPDF ≥ 6.0 |
|
NB Lists are handled as block-level elements as from mPDF 6.0 (see above) |
||
LI | list-style |
[ ‘list-style-type’ ‘list-style-position’ ‘list-style-image’ ] mPDF ≥ 6.0 |
list-style-type* * |
1 | A | a | I | i | disc | circle | square | decimal | lower-roman | upper-roman | lower-latin | upper-latin | lower-alpha | upper-alpha | none arabic-indic | bengali | cambodian | cjk-decimal | devanagari | gujarati | gurmukhi | hebrew |kannada | khmer | lao | malayalam | oriya | persian | telugu | thai | urdu | tamil “1” - decimal “A” = upper-latin “a” = lower-latin “I” = upper-roman “i” = lower-roman Custom list-style-type is recognised e.g.:
|
|
list-style-image |
<URI> mPDF ≥ 6.0 |
|
list-style-position |
inside | outside (default = outside) mPDF ≥ 6.0 |
|
NB Lists are handled as block-level elements as from mPDF 6.0 (see above) |
HTML Tag | Property | Values allowed & Notes |
---|---|---|
All Inline tags: SPAN, A, SUB, SUP, ACRONYM, BIG, SMALL, INS, S, STRIKE, DEL, STRONG, CITE, Q, EM, B, I, U, SAMP, CODE, KBD, TT, VAR, FONT, TIME, MARK | COMMON TEXT STYLES | See below |
border, border-top, border-bottom, border-left, border-right |
Size style and colour e.g. LENGTH solid|dotted|dashed|double COLOR (mPDF ≥ 5.4) |
|
border-color*, border-top-color, border-right-color, border-bottom-color, border-left-color |
COLOR (mPDF ≥ 5.4) |
|
border-width*, border-top-width, border-right-width, border-bottom-width, border-left-width |
LENGTH (mPDF ≥ 5.4) |
|
border-style*, border-top-style, border-right-style, border-bottom-style, border-left-style |
solid | dotted | dashed | double (mPDF ≥ 5.4) |
|
background-color, background | COLOR (only the color is supported in background) | |
display | none (mPDF ≥ 5.0) | |
visibility |
hidden | visible | printonly | screenonly (default = visible) (mPDF ≥ 5.7) |
|
hyphens |
none | manual | auto (default = manual) As per CSS. (mPDF ≥ 5.7) |
HTML Tag | Property | Values allowed & Notes |
---|---|---|
TABLE | background-color | COLOR |
background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (cf. Backgrounds & borders) (All except background-color added mPDF 5.1) |
|
background-image-resolution |
normal | [ from-image <dpi> ] (mPDF ≥ 5.1) |
|
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
COMMON TEXT STYLES | See below - except text-decoration, text-transform and text-shadow | |
border, border-right, border-left, border-top, border-bottom |
Size style and colour e.g. LENGTH double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none COLOR NB Table & cell borders accept: double | solid | dashed | dotted | ridge | outset | groove | inset (other block elements only support solid | dotted | dashed | double) |
|
border-color*, border-top-color, border-right-color, border-bottom-color, border-left-color |
COLOR (mPDF ≥ 4.0) |
|
border-width*, border-top-width, border-right-width, border-bottom-width, border-left-width |
LENGTH (mPDF ≥ 4.0) |
|
border-style*, border-top-style, border-right-style, border-bottom-style, border-left-style |
double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none (mPDF ≥ 4.0) |
|
padding*, padding-right, padding-left, padding-top, padding-bottom |
LENGTH (mPDF ≤ 1.3 incorrectly set cell-padding for all cells in table.) Sets table padding (only relevant when |
|
margin*, margin-right, margin-left, margin-top, margin-bottom | LENGTH | |
width | LENGTH | |
vertical-align | top | middle | bottom (applies to all cells in table) | |
text-align | left | right | center (applies to all cells in table; to centre a table on the page, you must use the align="center" attribute in the table tag) | |
border-collapse | collapse | separate | |
border-spacing |
Single or double values:
(Same as cellSpacing attribute) Default=2px |
|
empty-cells | hide | show (only relevant when border-collapse:separate) | |
page-break-inside | avoid | |
page-break-after |
left | right | always (mPDF ≥ 5.4) |
|
rotate |
rotates the table 90 degress clockwise (90) or counter-clockwise (-90). Does not work with columns, and bookmarks will not be correctly placed (custom attribute) | |
autosize |
Shrinks a table to fit if width is too small to allow complete words to fit. The value (must be ≥1) determines the maximum allowable factor to shrink i.e. `autosize="2"` will allow the font-size to be reduced to a minimum of 1/2 the original size. A value of 1 prevents automatic resizing of the table. (custom property) | |
topntail |
Sets border at top and bottom of table, and below THEAD row if present. (custom attribute) | |
thead-underline |
Sets border at bottom of THEAD row if present. (custom attribute added mPDF v1.1) | |
line-height | Sets default line-height for table cells as factor or % (value e.g. 1.3) | |
line-stacking-strategy |
inline-line-height | block-line-height | max-height | grid-height As per draft CSS3 spec. (mPDF ≥ 6.0) Default = inline-line-height |
|
line-stacking-shift |
consider-shifts | disregard-shifts As per draft CSS3 spec. (mPDF ≥ 6.0) Default = consider-shifts |
|
overflow |
auto | hidden | visible | wrap Controls table layout if minimum width is too wide for page. |
|
direction | rtl | ltr (mPDF ≥ 5.1) | |
CAPTION | caption-side | top | bottom (mPDF ≥ 5.4) Right and left are not supported |
THEAD, TFOOT | font-weight | normal | bold |
vertical-align | top | middle | bottom | |
text-align | left | center | right | |
TR | background-color | COLOR |
background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form url(image.png) or url(‘image.png’) or GRADIENT. background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (cf. Backgrounds & borders) (All except background-color added mPDF 5.1) |
|
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
border, border-right, border-left, border-top, border-bottom |
Size style and colour e.g. LENGTH double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none COLOR NB Table & cell borders accept: double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none (other block elements only support solid | dotted | dashed | double) (mPDF ≥ 5.1) |
|
border-color*, border-top-color, border-right-color, border-bottom-color, border-left-color |
COLOR (mPDF ≥ 5.1) |
|
border-width*, border-top-width, border-right-width, border-bottom-width, border-left-width |
LENGTH (mPDF ≥ 5.1) |
|
border-style*, border-top-style, border-right-style, border-bottom-style, border-left-style |
double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none (mPDF ≥ 5.1) |
|
text-rotate |
Rotate the text inside table cells for this row. Accepted values are 1 - 90 for degrees anticlockwise, or -90 (only) for clockwise rotation. (custom attribute) | |
:nth-child() SELECTOR* * |
odd | even | an+b As per CSS3 specification |
|
page-break-before, page-break-after |
avoid | allow Allows grouping of table rows and avoiding page breaks between two pages inside a group. since 8.2.4 |
|
TD, TH | background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (All except background-color added mPDF 3.2) |
background-gradient |
(Deprecated) GRADIENT_OLD (Added mPDF 3.2) |
|
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
background-image-resize |
0 - No resizing (default) 1 - Shrink-to-fit w (keep aspect ratio) 2 - Shrink-to-fit h (keep aspect ratio) 3 - Shrink-to-fit w and/or h (keep aspect ratio) 4 - Resize-to-fit w (keep aspect ratio) 5 - Resize-to-fit h (keep aspect ratio) 6 - Resize-to-fit w and h |
|
border, border-right, border-left, border-top, border-bottom |
Size style and colour e.g. LENGTH double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none COLOR NB Table & cell borders accept: double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none (other block elements only support solid | dotted | dashed | double) |
|
border-color*, border-top-color, border-right-color, border-bottom-color, border-left-color |
COLOR (mPDF ≥ 4.0) |
|
border-width*, border-top-width, border-right-width, border-bottom-width, border-left-width |
LENGTH (mPDF ≥ 4.0) |
|
border-style*, border-top-style, border-right-style, border-bottom-style, border-left-style |
double | solid | dashed | dotted | ridge | outset | groove | inset | hidden | none (mPDF ≥ 4.0) |
|
padding*, padding-right, padding-left, padding-top, padding-bottom | LENGTH | |
width | LENGTH | |
height | LENGTH (but not %) (mPDF ≥ 4.0) | |
COMMON TEXT STYLES | See below | |
white-space | nowrap | |
vertical-align | top | middle | bottom | |
text-align |
left | right | center From mPDF 5.7, also supports a decimal-mark alignment followed by a default e.g.
Non-ASCII characters should be defined using Unicode values:
|
|
text-rotate |
Rotates the text in a table cell. Accepted values are 1-90 for degrees anticlockwise, or -90 (only) for clockwise rotation. (custom attribute) | |
line-stacking-strategy |
inline-line-height | block-line-height | max-height | grid-height As per draft CSS3 spec. (mPDF ≥ 6.0) Default = inline-line-height |
|
line-stacking-shift |
consider-shifts | disregard-shifts As per draft CSS3 spec. (mPDF ≥ 6.0) Default = consider-shifts |
|
hyphens* * |
none | manual | auto (default = manual) As per CSS. (mPDF ≥ 5.7) |
|
:nth-child() SELECTOR |
odd | even | an+b As per CSS3 specification |
|
direction | rtl | ltr (mPDF ≥ 6.0) |
HTML Tag | Property | Values allowed & Notes |
---|---|---|
HR | width | LENGTH |
text-align | left | right | center | |
color | COLOR | |
height | i.e. line-width. LENGTH | |
margin-top, margin-bottom | LENGTH | |
margin-left, margin-right | auto | 0 (only) are supported as an alternative way to align a HR of less than 100% width. Values for margin-left: 0; margin-right: auto; will align the HR to the left etc. | |
clear | left | right | both | |
IMG | vertical-align |
top | middle | bottom | baseline | text-bottom | text-top (Full support only from mPDF 4.2) |
margin, margin-right, margin-left, margin-top, margin-bottom | LENGTH | |
border, border-right, border-left, border-top, border-bottom |
Must be full declaration of size style and colour e.g. 0.1pt solid | dotted | dashed #cccccc Will also accept and (from mPDF 1.4) medium | thin | thick accepted for size |
|
padding*, padding-right, padding-left, padding-top, padding-bottom | LENGTH | |
background-color | COLOR (mPDF ≥ 5.7.3) | |
opacity |
Value between 0 and 1.0 CSS3 recommended property (but already supported by Firefox) Sets the opacity/transparency of the image. |
|
image-orientation | ANGLE as deg, rad, or grad (as per draft CSS3) mPDF ≥ 5.1 | |
image-resolution |
normal | [ from-image <dpi> ] (as per draft CSS3) mPDF ≥ 5.1 |
|
image-rendering |
auto | crisp-edges | optimizequality | smooth (as per draft CSS3) (mPDF ≥ 6.0) Controls whether interpolation is on or off in PDF document. Once set for an image, subsequent use of the same image will use the initial setting for this property. auto (default) - uses the value set by config variable: crisp-edges - interpolation disabled optimizequality - interpolation enabled smooth - interpolation enabled |
|
gradient-mask |
GRADIENT_OLD mPDF ≥ 5.1 | |
display | none | |
visibility |
visible | hidden | printonly | screenonly (mPDF ≥ 5.4) |
|
transform |
All CSS3 transform functions are supported except matrix() i.e. translate(), translateX(), translateY() skew(), skewX(), skewY() scale(), scaleX(), scaleY() rotate() cf. http://www.w3.org/TR/css3-transforms/#typedef-transform-function |
|
float | left | right (cf. Images) | |
z-index | Sets a layer in the PDF document. See Layers. | |
(vspace, hspace) | Attributes - set values for margin-left/right or margin-top/bottom | |
width, height | LENGTH. NB the inline attributes `width=""` and `height=""` are also supported | |
min-width, min-height, max-width, max-height | LENGTH. (mPDF ≥ 5.6) | |
SELECT | font-family | FONT-FAMILY |
font-size | FONT-SIZE | |
color | COLOR | |
TEXTAREA | width, height | LENGTH. NB the inline attributes cols="" and rows="" are also supported |
font-family | FONT-FAMILY | |
font-size | FONT-SIZE | |
color | COLOR | |
vertical-align |
top | middle | bottom | baseline | text-bottom | text-top (Full support only from mPDF 4.2) |
|
border-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
background-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
INPUT (type=IMAGE) | width, height | LENGTH |
INPUT (type=BUTTON| SUBMIT|RESET) | font-family | FONT-FAMILY Active Forms only (mPDF ≥ 5.3) |
font-size | FONT-SIZE Active Forms only (mPDF ≥ 5.3) | |
color | COLOR Active Forms only (mPDF ≥ 5.3) | |
border-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
background-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
INPUT (type=CHECKBOX| RADIO) | font-size | FONT-SIZE (sets size of glyph). Not inherited. |
color | COLOR. Not inherited. | |
INPUT (type=PASSWORD| TEXT) | width | LENGTH. NB the inline attribute size="" is also supported |
font-family | FONT-FAMILY | |
font-size | FONT-SIZE | |
color | COLOR | |
border-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
background-color | COLOR Active Forms only (mPDF ≥ 5.3) | |
BR | clear | left | right | both |
DOTTAB |
outdent |
LENGTH. (mPDF ≥ 5.7) |
@page @page <named> | size |
<length>{1,2} | auto | portrait | landscape Note: ‘em’ ‘ex’ and % are not allowed Length values are width and height e.g. Sets the size of the ‘page-box’, which is usually used with a constant size sheet through the document, as in the CSS2 @paged media spec. |
sheet-size |
<length>{2} | A4 | A4-L etc. Note: ‘em’ ‘ex’ and % are not allowed Length values are width and height e.g. |
|
odd-header-name, even-header-name, odd-footer-name, even-footer-name |
A named Header or Footer. HTML headers/footers must precede the name with
NB This was the original form, and still takes preference over header and footer which can be set using the pseudo-selectors e.g. :right The name |
|
margin, margin-left, margin-right, margin-top, margin-bottom | LENGTH (% refers to page-box width for left/right, of height for top/bottom) | |
@page @page :right @page :left @page :first @page <named> | margin-top, margin-bottom |
LENGTH (% refers to page-box width for left/right, of height for top/bottom) Note that left and right margins cannot be changed when using a page selector. @page :first is not recognised unless @page has been set with some CSS properties |
margin-header, margin-footer |
LENGTH | |
marks |
crop | cross | none From mPDF 5.1 crop and cross can be used together. |
|
header, footer |
A named Header or Footer. HTML headers/footers must precede the name with
|
|
background, background-image, background-position, background-repeat, background-color |
background is parsed as per the CSS specification. background-image in the form background-position is supported as per CSS2.1 background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment is parsed but has no effect. See note below. (cf. Backgrounds & borders) |
|
background-image-opacity |
Value between 0 and 1.0 Sets the opacity/transparency of the background image. |
|
background-image-resize |
0 - No resizing (default) 1 - Shrink-to-fit w (keep aspect ratio) 2 - Shrink-to-fit h (keep aspect ratio) 3 - Shrink-to-fit w and/or h (keep aspect ratio) 4 - Resize-to-fit w (keep aspect ratio) 5 - Resize-to-fit h (keep aspect ratio) 6 - Resize-to-fit w and h |
|
background-gradient |
(Deprecated) GRADIENT_OLD | |
resetpagenum |
INTEGER Reset page numbering. Use with :first |
|
pagenumstyle |
1 | A | a | I | i See <pagebreak> for details | |
suppress |
on | off | 1 | 0 See <pagebreak> for details |
Common Text Styles
COMMON TEXT STYLES are:
font-family | FONT-FAMILY |
font-size | FONT-SIZE |
font-style | italic | oblique | normal |
font-weight | bold | normal (only) |
font | Shorthand form, as per CSS2 specification (mPDF ≥ 4.0) |
font-variant |
normal | none | [ <common-lig-values> <discretionary-lig-values> <historical-lig-values> <contextual-alt-values> historical-forms [ small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps ] <numeric-figure-values> <numeric-spacing-values> <numeric-fraction-values> ordinal slashed-zero ] (mPDF ≥ 6.0) |
font-variant-position |
normal | sub | super (mPDF ≥ 6.0) |
font-variant-caps |
normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps (mPDF ≥ 6.0) |
font-variant-ligatures |
normal | none | [ <common-lig-values> <discretionary-lig-values> <historical-lig-values> <contextual-alt-values> ] (mPDF ≥ 6.0) <common-lig-values> = [ common-ligatures | no-common-ligatures ] <discretionary-lig-values> = [ discretionary-ligatures | no-discretionary-ligatures ] <historical-lig-values> = [ historical-ligatures | no-historical-ligatures ] <contextual-alt-values> = [ contextual | no-contextual ] |
font-variant-numeric |
normal | [ <numeric-figure-values> <numeric-spacing-values> <numeric-fraction-values> ordinal slashed-zero ] (mPDF ≥ 6.0) |
font-variant-alternates |
Only [normal | historical-forms] supported (i.e. most are NOT supported) (mPDF ≥ 6.0) |
font-language-override |
3-letter case-sensitive OpenType language system tag (mPDF ≥ 6.0) |
font-feature-settings |
Comma separated list of <feature-tag-value> with the following syntax: <feature-tag-value> = <string> [ <integer> | on | off ]? (mPDF ≥ 6.0) |
font-kerning |
auto | normal | none (mPDF ≥ 5.1) auto and normal both have the effect of turning kerning on, as long as
|
vertical-align | super | sub | baseline | LENGTH (mPDF ≥ 5.7.3) |
letter-spacing | normal | LENGTH (mPDF ≥ 5.1) |
word-spacing | normal | LENGTH (mPDF ≥ 5.1) |
color | COLOR |
text-decoration |
underline | line-through | normal (line-through = strike-through) (mPDF ≥ 5.4) overline (mPDF ≥ 5.7.3) |
text-outline |
thickness [ blur ] color; OR none (default) Blur is not supported. As per CSS3 (mPDF ≥ 5.7) Supported in tables ≥ 6.0 |
text-outline-width, outline-width |
Width of the outline. LENGTH (text-outline-width as from mPDF ≥ 5.7) Supported in tables ≥ 6.0 |
text-outline-color, outline-color |
COLOR = colour of the inner part of the text e.g. #rrggbb. ‘INVERT’ is also accepted. (text-outline-color as from mPDF ≥ 5.7) Supported in tables ≥ 6.0 |
text-shadow | As per CSS3 specification. `blur` is not supported. (mPDF ≥ 5.4) |
text-transform | capitalize | uppercase | lowercase (mPDF ≥ 5.4) |
unicode-bidi |
normal | embed | isolate | bidi-override | isolate-override | plaintext (mPDF ≥ 6.0) When used on block-level elements:
|
Notes:
* Margin, padding, border-width, border-color and border-style accept the various shorthand forms e.g.:
margin: 1pt;
will set all top, right, bottom and left values the samemargin: 1pt 2pt;
will set top and bottom to 1pt, left and right to 2ptmargin: 1pt 2pt 3pt;
will set top to 1 pt, left and right to 2 pt, and bottom to 3 pt (mPDF ≥ 4.0)margin: 1pt 2pt 3pt 4pt;
will set all values in order:top > right > bottom > left
NB Table page-break-inside, autosize values and rotate are only respected for that set on first level table of nested tables
Border
medium | thin | thick are accepted for size - converted to 1px, 3px, 5px