dompdf supports the following CSS selector syntaxes. dompdf also supports elements with multiple class attributes (e.g. <p class="red bold">foo</p>
matches p.red
and p.bold
).
Note that the CSS selectors are case sensitive in dompdf (e.g. .foo
will not match <div class="FOO">bar</div>
)
Selector |
Supported |
Version Added |
Notes |
* |
yes |
|
|
E |
yes |
|
|
E F |
yes |
|
|
E > F |
yes |
|
|
E.class |
yes |
|
|
E#myid |
yes |
|
|
E:root |
yes |
2.0.2 |
|
E:first-child |
yes |
|
|
E:last-child |
yes |
0.6.0 |
|
E:only-child |
yes |
2.0.2 |
|
E:first-of-type |
partial |
0.6.0 |
|
E:last-of-type |
partial |
0.6.0 |
|
E:only-of-type |
partial |
2.0.2 |
|
E:nth-child |
yes |
0.6.0 |
|
E:nth-last-child |
yes |
0.6.0 |
Parsed as nth-child until 0.8.0 |
E:nth-of-type |
partial |
0.6.0 |
|
E:nth-last-of-type |
partial |
0.6.0 |
Parsed as nth-of-type until 0.8.0 |
E:empty |
yes |
|
|
E:link |
yes |
|
|
E:any-link |
yes |
2.0.2 |
|
E:visited |
N/A |
|
|
E:active |
N/A |
|
|
E:hover |
N/A |
|
|
E:focus |
N/A |
|
|
E:lang(c) |
no |
|
|
E + F |
yes |
|
Behaved as E ~ F until 1.1.0 |
E ~ F |
yes |
1.1.0 |
|
E[foo] |
yes |
|
|
E[foo="warning"] |
yes |
|
|
E[foo~="warning"] |
yes |
|
|
E[foo$="warning"] |
yes |
0.6.0 |
|
E[foo^="warning"] |
yes |
0.6.0 |
|
E[foo*="warning"] |
yes |
0.6.0 |
|
E[lang|="en"] |
yes |
|
|
Page Selectors |
Supported |
Version Added |
Notes |
@page |
yes |
|
|
@page :left |
yes |
0.6.0 |
only margins are applied |
@page :right |
yes |
0.6.0 |
only margins are applied |
@page :odd |
yes |
0.6.0 |
only margins are applied |
@page :even |
yes |
0.6.0 |
only margins are applied |
@page :first |
yes |
0.6.0 |
only margins are applied |
Property |
Supported |
Version Added |
Notes |
E::first-line |
no |
|
|
E::first-letter |
no |
|
|
E::before |
yes |
|
Only on block and inline elements |
E::after |
yes |
|
Only on block and inline elements |
dompdf supports the majority of CSS 2.1 properties and some CSS 3 properties. See the following table for details on which properties are supported.
Property |
Supported |
Version Added |
Notes |
background-attachment |
N/A |
|
|
background-color |
yes |
|
|
background-image |
yes |
|
|
background-position |
yes |
|
|
background-repeat |
yes |
|
|
background-size |
yes |
0.8.6 |
|
background |
yes |
|
Supports setting background-position and background-size since 1.2.0 |
border-collapse |
yes |
|
|
border-color |
yes |
|
|
border-radius |
yes |
0.6.0 |
Supported on inline elements since 2.0.0. Only supports single radius value per corner |
border-spacing |
yes |
|
|
border-style |
yes |
|
|
border-top |
yes |
|
|
border-top-color |
yes |
|
|
border-top-style |
yes |
|
|
border-top-width |
yes |
|
|
border-width |
yes |
|
|
border |
yes |
|
|
bottom |
yes |
|
Supported for relative positioning since 1.1.0 |
box-shadow |
no |
|
|
box-sizing |
no |
|
|
caption-side |
no |
|
Caption elements are moved before the table, as block elements |
clear |
partial |
0.6.0 |
In 0.6.x DOMPDF_ENABLE_CSS_FLOAT must be true |
clip |
no |
|
|
color |
yes |
|
|
content |
yes |
|
|
counter-increment |
yes |
|
|
counter-reset |
yes |
|
Multiple counters supported with 1.2.0 |
cursor |
N/A |
|
|
direction |
no |
|
|
display |
partial |
|
Display type run-in is not supported |
empty-cells |
yes |
0.6.0 |
|
float |
partial |
0.6.0 |
In 0.6.x DOMPDF_ENABLE_CSS_FLOAT must be true |
font-family |
yes |
|
|
font-size |
yes |
|
|
font-stretch |
no |
|
|
font-style |
yes |
|
|
font-variant |
no |
|
|
font-weight |
yes |
|
Numeric font weights supported since 0.8.4. bolder and lighter keywords supported since 3.0.0 |
font |
yes |
|
|
height |
yes |
|
|
inset |
yes |
2.0.0 |
|
left |
yes |
|
|
letter-spacing |
yes |
|
Not supported when using the GD backend |
line-height |
yes |
|
|
list-style-image |
yes |
|
|
list-style-position |
yes |
|
|
list-style-type |
yes |
|
|
list-style |
yes |
|
|
margin-right |
yes |
|
|
margin-top |
yes |
|
|
margin |
yes |
|
|
max-height |
partial |
|
|
max-width |
yes |
|
Supported on table cells since 1.1.0 (only absolute values) |
min-height |
partial |
|
|
min-width |
yes |
|
Supported on table cells since 1.1.0 (only absolute values) |
opacity |
yes |
|
Supports percentage values since 2.0.0. Not supported when using the GD backend |
orphans |
yes |
|
|
outline-color |
yes |
|
|
outline-offset |
yes |
1.1.0 |
|
outline-style |
yes |
|
|
outline-width |
yes |
|
|
outline |
yes |
|
Takes border radius into account since 1.1.0. Supported on inline elements since 2.0.0 |
overflow |
partial |
|
|
overflow-wrap |
yes |
1.1.0 |
|
padding-top |
yes |
|
|
padding |
yes |
|
|
page-break-after |
yes |
|
Supported on table rows since 1.1.0. Not supported on table row groups |
page-break-before |
yes |
|
Supported on table rows since 1.1.0. Not supported on table row groups |
page-break-inside |
yes |
|
Not supported on table row groups |
position |
yes |
|
|
quotes |
yes |
|
|
right |
yes |
|
Supported for relative positioning since 1.1.0 |
size |
yes |
|
for @page |
src |
partial |
|
for @font-face |
table-layout |
yes |
0.6.0 |
|
text-align |
yes |
|
|
text-decoration |
yes |
|
|
text-indent |
yes |
|
|
text-shadow |
no |
|
|
text-transform |
yes |
|
|
transform |
yes |
|
Except for 3D transformations |
transform-origin |
yes |
|
|
top |
yes |
|
|
unicode-bidi |
no |
|
|
unicode-range |
no |
|
for @font-face |
vertical-align |
yes |
|
|
visibility |
yes |
|
|
white-space |
yes |
|
|
widows |
no |
|
|
width |
yes |
|
auto support added in 0.7.1 |
word-break |
no |
|
Supports the deprecated break-word keyword only since 2.0.0 |
word-spacing |
yes |
|
Not supported when using the GD backend |
word-wrap |
yes |
0.6.0 |
Alias of overflow-wrap since 1.1.0 |
z-index |
yes |
|
|
--* |
yes |
3.0.0 |
double-dash prefix custom properties syntax |
Keyword |
Supported |
Version Added |
Notes |
initial |
yes |
1.2.0 |
|
inherit |
yes |
|
|
unset |
yes |
1.2.0 |
|
revert |
no |
|
|
Unit |
Supported |
Version Added |
Notes |
px |
yes |
|
|
pt |
yes |
|
|
% |
yes |
|
|
rem |
yes |
0.6.0 |
|
em |
yes |
|
|
cm |
yes |
|
|
mm |
yes |
|
|
ex |
yes |
|
Equals to em/2 |
in |
yes |
|
|
pc |
yes |
|
|
rad |
yes |
0.6.0 |
for 2D transforms |
deg |
yes |
0.6.0 |
for 2D transforms |
grad |
yes |
3.0.0 |
for 2D transforms |
turn |
yes |
3.0.0 |
for 2D transforms |
Color |
Supported |
Version Added |
Notes |
transparent |
yes |
|
|
currentcolor |
yes |
1.2.0 |
|
Basic color keywords |
yes |
|
|
Extended color keywords |
yes |
|
|
Numerical color values |
yes |
|
|
CMYK color values |
yes |
0.8.0 |
|
RGBA color values |
yes |
0.7.0 |
transparency was ignored prior to 0.7.1; space-separated syntax supported with 1.2.0 |
HSL color values |
no |
|
|
HSLA color values |
no |
|
|
CSS2 system colors |
no |
|
|
Function |
Supported |
Version Added |
Notes |
calc |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
min |
yes |
3.0.0 |
|
max |
yes |
3.0.0 |
|
clamp |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
round |
partial |
3.0.0 |
does not support rounding strategy or interval |
mod |
yes |
3.0.0 |
|
rem |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
sin |
yes |
3.0.0 |
|
cos |
yes |
3.0.0 |
|
tan |
yes |
3.0.0 |
|
asin |
yes |
3.0.0 |
|
acos |
yes |
3.0.0 |
|
atan |
yes |
3.0.0 |
|
atan2 |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
pow |
yes |
3.0.0 |
|
sqrt |
yes |
3.0.0 |
|
hypot |
yes |
3.0.0 |
|
log |
yes |
3.0.0 |
|
exp |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
abs |
yes |
3.0.0 |
|
sign |
yes |
3.0.0 |
|
Function |
Supported |
Version Added |
Notes |
attr |
partial |
|
only parsed by the content property; does not support type or unit specification; does not support fallback value |
url |
partial |
|
does not support SVG paths (element identifiers) |
var |
yes |
3.0.0 |
|