- Type: string (representing an integer)
- The preferred width of the element. The value should not include a unit as all values are in pixels. The actual displayed width may be different if the element or its contents have a minimum or maximum width, or the size is adjusted by the flexibility or alignment of its parent. The CSS width property may also be used.
In this example, the preferred width of the inner hbox will be displayed at 40 pixels. The displayed width is also 40 pixels as no flexibility or alignment applies.
<hbox> <hbox width="40" style="background-color: red;"> <label value="40"/> </hbox> </hbox>
However, in the following example, despite that the preferred width of the box is 30 pixels, the displayed size of the box will be larger to accommodate the larger label.
<vbox width="30" align="start" style="background-color: red;"> <label value="vbox xul width 10px red"/> </vbox>
widthattribute can be used to allow a tree to be scrolled horizontally if the column widths add up to be wider than the containing object.