I didn't have this issue before. It was brought to my attention only recently, so I don't know for how long this issue remained online. No code was changed / modified in the last year or so.
Using phpdocx-corporate-5.5, PHP 7.4.18
$style = "<style type='text/css'>
h1 { page-break-before:always; }
h1:first-child { page-break-before:avoid; }
p.sample { font-weight:bold; background-color:#FFFF00; }
p.empty { color:#fff; background-color:blue; }
.tbl-summary { border-collapse:collapse; font-size:12px; }
.tbl-summary thead tr th { font-weight:bold; }
.tbl-summary thead tr th,
.tbl-summary thead tr td,
.tbl-summary tbody tr td
{
border:1px solid #000000;
padding:2px;
text-align:center;
width:100px;
}
.tbl-summary tbody tr td:first-child
{
text-align:left;
}
</style>";
$html = $style;
$html .= "<p class='sample'>Test</p>";
.
.
.
$docx->embedHTML($html);
All the html code gets displayed properly. But this style code is showing as text in the docx. It's not getting inserted as a CSS style.
h1 { page-break-before:always; } h1:first-child { page-break-before:avoid; } p.sample { font-weight:bold; background-color:#FFFF00; } p.empty { color:#fff; background-color:blue; } .tbl-summary { border-collapse:collapse; font-size:12px; } .tbl-summary thead tr th { font-weight:bold; } .tbl-summary thead tr th, .tbl-summary thead tr td, .tbl-summary tbody tr td { border:1px solid #000000; padding:2px; text-align:center; width:100px; } .tbl-summary tbody tr td:first-child { text-align:left; }