Perl CGI Programming
HTML Elements: Formatted Lists
- The <UL> tag allows you to create an unordered list of
items.
- Within this list, you tag each separate element with the <LI>
construct.
- The raw HTML to generate this list would be:
<UL ALIGN="center">
<LI TYPE="disc">List Entry One</LI>
<LI TYPE="disc">List Entry Two</LI>
<LI TYPE="disc">List Entry Three</LI>
</UL>
The Perl CGI construct for creating an unordered list would be:
# Try an unordered list
print $query->hr();
print "This should be a centered unordered list of three elements\n";
print $query->ul({-align=>'center'},
$query->li({-type=>'disc'},
['List Entry One',
'List Entry Two',
'List Entry Three']));
print $query->hr();
Note that the manually inserted array elements could also have
been simply the name of a prebuilt array of scalers (which would have
been much more readable).
Note that other lists (i.e. ordered) would be done the same way.
For example:
# Try an orderd list
my @myList = ['List Entry One', 'List Entry Two', 'List Entry Three'];
print $query->hr();
print "This should be a left justified ordered list of three elements\n";
print $query->ol({-align=>'LEFT'},
$query->li(@myList));
print $query->hr();
Back to Syllabus
Previous: HTML Elements: Hyperlinks
Next: HTML Elements: Tables