7

I wonder why there is no tree tag in html? Something like table tag.

For example:

<tree>
  <treenode id=root>
    <treenode id=child1 />
    <treenode id=child2>
       <treenode id=child2-1>
       ......
       </treenode>
    </treenode>
  </treenode>
</tree>

Edit: well actually I did not get a clear answer to this question. I think this was not a valid question. But putting the answer from cherouvim beside comment from Anwar Chandra together, I think I've got the answer to my question.

5
  • 6
    You're going to have to explain a lot more before you'll get reasonable answers. What do you mean by "tree"? Binary tree? Tree of bulleted lists (nested <ul>s)? Christmas tree?
    – Tim
    Dec 10, 2009 at 17:29
  • +1 for the Christmas tree, Tim :-). aforloney: That was simply the lack of formatting in the source.
    – Joey
    Dec 10, 2009 at 17:32
  • Yeah, just noticed that once the edit came around :x Dec 10, 2009 at 17:33
  • because there's DOM trees, other tree will make us confusing. Dec 10, 2009 at 17:44
  • "...Yeah, just noticed that once the edit came around :x ..." Sorry, actually it was my first post here and did'nt notice code formating. "... You're going to have to explain a lot more before you'll get..." Well I thought when I say "like table tag" it is clear what I mean. I encountered the question as I was working with RichFaces and wanted to write a javascript to do something with their tree. But the tree is on the client side implemented as combination of table and divs.
    – zardosht
    Dec 23, 2009 at 14:16

2 Answers 2

14

There is. Nested lists (ul, or ol).

<ul>
    <li>foo</li>
    <li>bar</li>
    <li>test
        <ul>
            <li>foo</li>
            <li>bar</li>
        </ul>
    </li>
    <li>example</li>
</ul>

And with the help of CSS and JS you can make the tree look and interact like, for example, the windows explorer.

2
  • 2
    Uh, no, there isn't. Still +1. Dec 10, 2009 at 17:34
  • Well, yes. Technically there isn't :)
    – cherouvim
    Dec 10, 2009 at 17:38
0

If you say: ok a directory structure is some kind of technical glossary, the DL/DD/DT construction might be a good solution.

The difference to the usage of <ul> is that you can seperate the foldername and the childrens.

<dl>
  <dt>C:</dt>
  <dd>
     <dl>
       <dt>WINDOWS</dt>
       <dt>USERS</dt>
       <dt>ProgramData</dt>
     </dl>
  </dd>
</dl>
C:
  WINDOWS
  USERS
  ProgramData

Beware: Neither DL nor UL/OL is a perfect match for directory-structures. You could add your very own, custom tags to have a better match like <folder>.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.