Word Wrapping Style


It is not so easy to get text word wrap when displayed, since browsers recognize different word wrap style commands.

Below find an example of a table with columns of different widths and word wrap.
The column width will automatically adjust to the length of the longest word in that column.

The word wrapping style can be applied to any object that allows the style HTML command.

dim db$(6,10)
 
'fill array with information
for i = 0 to 10
  for j = 0 to 6
    db$(j,i) = str$(j)+" ... "+str$(i)
  next
next
 
'Word-Wrap style for different browsers
WordWrap$ = "style='white-space: pre-wrap;";_
                   "white-space: -moz-pre-wrap;";_
                   "white-space: -pre-wrap;";_
                   "white-space: -o-pre-wrap;";_
                   "word-wrap: break-word'"
 
'create a table with a width expressed in Inch or Metric units
html "<table style='width:8in' border=1>"
'html "<table style='width:200mm' border=1>"
 
'create the table rows
for i = 0 to 10
  html "<tr>"
    html "<td width=15% " +WordWrap$+ ">"
      handle$ = "#tableLink."; i
      link #handle$, db$(0,i), [goHere]
    html "</td>"
    html "<td width=10% " +WordWrap$+ ">" +db$(1,i)+ "</td>"
    html "<td width=15% " +WordWrap$+ ">" +db$(2,i)+ "</td>"
    html "<td width=40% " +WordWrap$+ ">" +db$(3,i)+ "</td>"
    html "<td width=5%  " +WordWrap$+ ">" +db$(4,i)+ "</td>"
    html "<td width=10% " +WordWrap$+ ">" +db$(5,i)+ "</td>"
    html "<td width=5%  " +WordWrap$+ ">" +db$(6,i)+ "</td>"
  html "</tr>"
next
 
'end the table
html "</table>"
wait
 
'display the row number of the selected link
[goHere]
  myRow = val(word$(EventKey$, 2, "."))
  print "You selected Row ... "; myRow
  wait