Replies: 1   Views: 1869
Styling <ul> lists
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by pwctechnicalsecurity  · 21-10-2019 - 20:38


Hopefully one of the last questions. I have created a simple list like:

  <li>item 1</li>
  <li>item 2</li>

I tried to apply a style that was defined in my base template. As I am using the embedHTML function, I initially tried to apply a style through either a <ul> key, a <li> key or a class that I set on the <ul> element, like <ul class='xxx'>. Moreover, I explored the Premium customizeWordContent functions with the following function:

    'type' => 'list'
), array(
        'pStyle' => 'ListRed',

Neither one of those seem to help; yet I would like to apply a liststyle that I have set in my base template. Any suggestions?

Posted by admin  · 22-10-2019 - 08:11


MS Word style can be applied to HTML lists setting the customListStyles option as true. On you can find the following sample:

$latinListOptions = array();
$latinListOptions[0]['type'] = 'lowerLetter';
$latinListOptions[0]['format'] = '%1.';
$latinListOptions[1]['type'] = 'lowerRoman';
$latinListOptions[1]['format'] = '%1.%2.';
$docx->createListStyle('latin', $latinListOptions);

$html = '<ul class="latin">
    <li>First item.</li>
    <li>Second item with subitems:
            <li>First subitem.</li>
            <li>Second subitem.</li>
    <li>Third subitem.</li>
$docx->embedHTML($html, array('customListStyles' => true));

Note that lists always include a numbering style and can also have a paragraph style; both styles can be applied to the same list. DOCXCustomizer can be very useful for this tasks, and the parseStyles method returns the information about existing styles, maybe you are not applying the correct style name/id.

As this is a very specific task, we recommend you to open a ticket ( and attach your template. The dev team can generate a custom sample using your template.