CSS alone cannot do that, there may be a lot of childs, who are not going to write a CSS child selector for N elements, are you? For this reason JavaScript is used to create a loop for those N elements, and to attach a visual representation (or a class to each of those elements). This way, the first element is parent then later ones are simply files or child folders and so on.
There are many libraries already provided online, Google for
treeview jquery[
^]. You will get more than 20 plugins to chose from.
jsTree[
^] is one of them.