« XUL Reference home [ Examples | Attributes | Properties | Methods | Related ]

A column of a tree. It displays the column header and holds the size and other information about the column. You can also place splitter elements between the columns to allow column resizing. You should always place an id attribute on a treecol element to ensure that the column positioning is handled properly.

More information is available in the XUL tutorial.

crop, cycler, dragging, editable, fixed, hidden, hideheader, ignoreincolumnpicker, label, primary, sort, sortActive, sortDirection, src, type, width
Style classes



This example shows a checkbox in the first column, requires the style below.

<tree flex="1" editable="true">

    <treecol label="Active" type="checkbox" editable="true"/>
    <treecol label="Name" flex="1" />

        <treecell value="true"/>
        <treecell label="Alice"/>
        <treecell value="false"/>
        <treecell label="Bob"/>


To make the checkbox visible on some platforms, the following styles need to be added to the stylesheet (see treecol.type). On Firefox 2.x and 3.x, all operating systems other than Mac OS X already use these styles by default. If targeting Firefox for Mac OS X, be sure to use these styles but include your own checkbox image. However, chrome://global/skin/checkbox/cbox-check.gif is available in SeaMonkey on Mac OS X..

treechildren::-moz-tree-checkbox {
  /* unchecked checkbox treecells. This style MUST come before treechildren::-moz-tree-checkbox(checked) otherwise it won't take effect.  */
  list-style-image: none;

  /* css for checked cells. cbox-check.gif isn't available in Firefox 1, 2, and 3 on Mac OS X, so you should specify a URL to an image
     in your extension or elsewhere. */
  list-style-image: url("chrome://global/skin/checkbox/cbox-check.gif");

For example:

  1. Create a CSS file.
  2. Copy and paste the code above and link the CSS file to your XUL file.
  3. Reload the page to see the checkbox.
  4. If you want, you can also style the tree using CSS.


Type: one of the values below
If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
The text will be cropped on its left side in left-to-right text locales, and the right side in right-to-left locales.
The text will be cropped on its right side in left-to-right text locales, and the right side in right-to-left locales.
The text will be cropped on its left side.
The text will be cropped on its right side.
The text will be cropped in the middle, showing both the start and end of the text normally.
The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
Depending on the platform and theme being used, some elements will have set a maximum width so they will always appear cropped. If you wish to use the value none and the displayed text is larger than this maximum width, you may be able to use the max-width CSS property (or the maxwidth attribute) to override this size. For example, for a menuitem in a menu you can add the following CSS rule when you want to use the value none:
menupopup > menuitem, menupopup > menu { max-width: none; }
Type: boolean
If true, then the column is a cycler column. In the case, clicking on a cell in the column will alternate its state between on and off. This is used, for example, in a mail window, for a column that indicates that the message is read or unread with a small mark in the cell. If the cycler attribute is not set, the cell is a regular text cell.
Type: boolean
This attribute will be set to true if the column is being dragged. This attribute is set automatically; you shouldn't adjust it yourself.
Type: boolean
Allows the contents of cells in the column to be changed, especially useful when type="checkbox". When the user double-clicks an editable cell, a text field appears in which the user can edit the contents of the cell.
The tree must also be marked as editable in order for this to work. Individual treecell elements in the column may be marked editable="false" in order to disable editing.
Type: boolean
If true, the size of the column in the tree cannot be adjusted by the user. Any splitter to either side will resize those columns while keeping the fixed column at a constant size. If false or not specified, the user can adjust the size of the column, typically by dragging the column header with the mouse.
Type: boolean
If set to true, the element is not displayed. This is similar to setting the CSS display property to 'none'.
Type: boolean
Set this to true to indicate that the tree column header should be displayed without any column header styling. If you don't set a label for that column either, the header is not displayed at all.
Type: boolean
If true, the column does not appear in the column picker.
Type: string
The label that will appear on the element. If this is left out, no text appears. For an editable menuitem element the value of this attribute is copied to the menulist.value property upon user selection of the menuitem.
Type: boolean
If set to true, the treecol will have indentation and twisties drawn to the left of it to indicate the hierarchy level of the rows. If no column has the primary attribute set to true, the tree may still contain nested rows, although no indication will be given to the user.  The attribute also controls whether the column picker allows the user to deselect this column.
Type: URI or XML attribute
Set this to a RDF property or XML attribute to have the data in the column sorted based on that property. The property will usually be the same as that of the cell label.
Type: boolean
This should be set to true for the column which should be sorted by default.
Type: one of the values below
Set this attribute to set the direction that template-generated content is sorted. Use the sortResource attribute to specify the sort key.
The data is sorted in ascending order.
The data is sorted in descending order.
The data is sorted in natural order, which means the order that it is stored in.
Type: URI
Set this attribute to have the treecol element use an image for the header instead of a label. You cannot have both an image and a label displayed in the header. Set this to the URL of an image to appear on the tree column header. If this attribute is left out, no image appears and the label is used instead. The class treecol-image must be used on the treecol element for the image to appear. You should still specify a label for use in the column picker if ignoreincolumnpicker is not true and hidecolumnpicker is not true on the tree.
Type: one of the values below
The type of tree column. The default is a text column that displays the content as text.
The content of the columns are checkboxes.
The content of the columns are a progress meters. This is used in Mozilla's download manager window.
The content of the columns is text.
Type: string (representing an integer)
The preferred width of the tree column. The value should not include a unit as all values are in pixels. Specifying widths for your columns causes Gecko to allow the tree to be scrolled horizontally if it is wider than the available space.


Type: integer
A value indicating the type of accessibility object for the element.

Inherited Properties
align, , allowEvents, , boxObject, builder, , , , className, , , , , collapsed, contextMenu, controllers, database, datasources, dir, , , flex, height, hidden, id, , , left, , maxHeight, maxWidth, menu, minHeight, minWidth, , , , , , , observes, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statusText, style, ,, tooltip, tooltipText, top, width


Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature, getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

Style classes

The following class may be used to style the element. This class should be used instead of changing the style of the element directly since it will fit more naturally with the user's selected theme.

Use this class to have an image appear on the tree column header. Specify the image using the src attribute.
tree, treecols, treechildren, treeitem, treerow, treecell and treeseparator.