The IBM® Toolbox for Java™ HTMLAlign class enables you to align sections of your HTML document, instead of just aligning individual items such as paragraphs or headings.
The HTMLAlign class represents the <DIV> tag and its associated align attribute. You can use right, left, or center alignment.
You can use this class to perform a variety of actions that include the following:
// Create an unordered list.
UnorderedList uList = new UnorderedList();
uList.setType(HTMLConstants.DISC);
UnorderedListItem uListItem1 = new UnorderedListItem();
uListItem1.setItemData(new HTMLText("Centered unordered list"));
uList.addListItem(uListItem1);
UnorderedListItem uListItem2 = new UnorderedListItem();
uListItem2.setItemData(new HTMLText("Another item"));
uList.addListItem(uListItem2);
// Align the list.
HTMLAlign align = new HTMLAlign(uList, HTMLConstants.CENTER);
System.out.println(align);
The previous example produces the following tag:
<div align="center">
<ul type="disc">
<li>Centered unordered list</li>
<li>Another item</li>
</ul>
When you use this tag in an HTML page, it looks like this: