HTML Attributes
HTML tag Attributes (in-line) supported
Example of an HTML attribute: <div align="center">
mPDF supports attribute values in single or double quotes e.g. <div align="center"> or <div align='center'>
Minimised attributes are not supported e.g. <input type="checkbox" disabled />
XHTML specification is recommended for best compliance with mPDF.
Note: The attributes $class, $id and $style are supported on most HTML tags: see
Supported CSS for details.
| HTML, BODY and ALL recognised tags | lang* | LANGUAGE-COUNTRY CODE * |
| dir | rtl | ltr (mPDF ≥ 6.0) | |
| HTML, BODY | dir | rtl | ltr (mPDF ≥ 5.0) |
| P, DIV | align | left | center | right | justify |
| TABLE | border | 1 | 0 |
| width | LENGTH | |
| align |
left | center | right | char char was added in mPDF 5.7 |
|
| char |
Used in conjunction with |
|
| bgcolor | #rrggbb | |
| cellSpacing | LENGTH | |
| cellPadding | LENGTH | |
| (repeat_header) |
1 (removed from mPDF ≥ 5.4; use |
|
| autosize |
FLOAT
|
|
| rotate | 90 | -90 | |
| TR | bgcolor | #rrggbb |
| TD, TH | width | LENGTH |
| height | LENGTH (but not %) | |
| align | left | center | right | |
| valign | top | middle | bottom | |
| bgcolor | #rrggbb | |
| colspan | INTEGER | |
| rowspan | INTEGER | |
| nowrap | nowrap | |
| OL, UL | font-size | FONT-SIZE |
| OL | type | 1 | A | a | I | i | disc | circle | square |
| start | INTEGER (mPDF ≥ 5.7) | |
| UL | type | disc | circle | square |
| IMG | width, height | LENGTH |
| max-height, max-width, min-height, min-width | LENGTH | |
| rotate |
90 | -90 | 180, where 90 = clockwise When width is specified e.g. |
|
| HR | width | nn% |
| align | left | center | right | |
| color | #rrggbb | |
| FONT | face | FONT-FAMILY |
| size | 1 | 2 | 3 | 4 | 5 | 6 | 7 | -1 | +1 | |
| color | #rrggbb | |
| FORM | method |
get | post Default: post (mPDF ≥ 5.3) |
| action | URI (mPDF ≥ 5.3 | |
| TEXTAREA | cols | INTEGER |
| rows | INTEGER | |
| readonly | readonly | |
| required | required [HTML5] (mPDF ≥ 5.3) | |
| spellcheck |
true | false [HTML5] Default: false (mPDF ≥ 5.3) |
|
| onChange |
JAVASCRIPT In Active Forms; uses “Acrobat” Javascript (mPDF ≥ 5.3) |
|
| TEXTAREA, SELECT, INPUT | disabled | disabled |
| title | TEXT | |
| name |
TEXT Field names in Active Forms must only contain letters, numbers,
colon( |
|
| SELECT | size |
INTEGER size = n, n rows visible. Default: 1 |
| multiple | multiple | |
| required | required [HTML5] (mPDF ≥ 5.3) | |
| spellcheck |
true | false [HTML5] Default: false (mPDF ≥ 5.3) Only if also editable and size=1 |
|
| editable |
editable [HTML5] Default: false (mPDF ≥ 5.3) Only if size=1 |
|
| onChange |
JAVASCRIPT In Active Forms; uses “Acrobat” Javascript (mPDF ≥ 5.3) |
|
| OPTION | selected | selected |
| value | TEXT | |
| INPUT | type | text | password | hidden | image | button | submit | reset | radio | checkbox |
| INPUT (text, password, hidden, image, button, submit, reset) | size |
INTEGER size=n, width as number of characters |
| value | TEXT | |
| INPUT (text, password) | maxlength | INTEGER |
| readonly | readonly | |
| required | required [HTML5] (mPDF ≥ 5.3) | |
| spellcheck | true \| false [HTML5] Default: false (mPDF ≥ 5.3) | |
| onChange |
JAVASCRIPT In Active Forms; uses “Acrobat” Javascript (mPDF ≥ 5.3) |
|
| INPUT (image, button, submit, reset) | alt | TEXT |
| src | TEXT | |
| onClick |
JAVASCRIPT In Active Forms; uses “Acrobat” Javascript (mPDF ≥ 5.3) |
|
| INPUT (button, submit, reset) | noprint | noprint (mPDF ≥ 5.3) |
| INPUT (radio, checkbox) | value |
TEXT In Active Forms value(s) for radio buttons and checkboxes are
required, and can only contain letters, numbers, colon( |
| DOTTAB | outdent | LENGTH (mPDF ≥ 5.7) |
| METER | value, max, min, low, high, optimum | FLOAT [HTML5 spec] |
| PROGRESS | value, max | FLOAT [HTML5 spec] |
| METER, PROGRESS | width, height | LENGTH |
| type |
Any alphanumeric string. If present, will select custom progress/meter formats - IF they have been
defined in |
* $lang is only recognised when the variable
$useLang is set to
true (Default is true)
Note: Table page-break-inside, autosize values and rotate are only respected for that set on first level table of nested tables
Note: Attributes like nowrap, disabled, multiple, readonly, selected and checked are only supported in
their formal/long form i.e. selected="selected"
Note: LANGUAGE-COUNTRY CODE accepts codes for
$lang according to the
HTML specification. e.g.
"en", "en-US", "fr", "zh-HK". The settings for these languages are defined in the
\Mpdf\LangToFont class. Other codes for character sets (or codepages) are recognised - see
\Mpdf\Mpdf::__construct().
Changelog
| Version | Description |
|---|---|
| 2.0 |
TD |
|
TABLE |
|
| 2.3 | $lang was added. |
| 4.0 |
Default value of $lang changed to |
| 5.0 | $dir was added to HTML and BODY |