This Gist provides a PHP function used for displaying nicely formatted tree using CSS only. It supports multiple levels (no limit).
The HTML output is clean and indented. For example :
<ul class="tree level-0">
<li class="folder">John: <span class="comment">John's home directory</span>
<ul class="level-1">
<li class="folder">Documents: <span class="comment">John's documents</span>
<ul class="level-2">
<li class="folder">Personal
<ul class="level-3">
<li class="file">Résumé.pdf</li>
</ul>
</li>
<li class="folder">Professional</li>
</ul>
</li>
<li class="folder">Music: <span class="comment">John's music</span></li>
<li class="folder">Videos: <span class="comment">John's videos</span>
<ul class="level-2">
<li class="file">my-baby-2017.mp4</li>
<li class="file">holidays-in-usa.avi</li>
</ul>
</li>
<li class="folder">Sites: <span class="comment">John's sites</span></li>
</ul>
</li>
<li class="folder">Helen: <span class="comment">Helen's home directory</span>
<ul class="level-1">
<li class="folder">Music: <span class="comment">Helen's music</span></li>
<li class="folder">Sites: <span class="comment">Helen's sites</span></li>
</ul>
</li>
</ul>