Forum Moderators: not2easy

Message Too Old, No Replies

Pre tag contents are not wrapped

         

ravi

7:02 am on Oct 30, 2008 (gmt 0)

10+ Year Member



Hai,

I am using the Pre to display the contents.But it is not wrapped on IE,The screen is scrolling horizontally upto contents.

When i try to apply the css it is not working in IE but it is fine Firefox 3.1

Can anyone help me to fix this issue.
Code
=====
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
<style type="text/css">
pre {
font-size:11px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* inter*/

}
.textWithoutBold {
font-size:12px;
}
</style>
</HEAD>
<BODY>
<table width="60%" border="0">
<tr>
<td width="100%" valign="top" colspan="4">
<div>
<pre> You CAN affect your sewer rate!
Reducing the amount of water you use can have a large effect on your water and sewer bill. Earlier this year, the City Council adopted a methodology for variable sewer rates based on water usage. Instead of a flat fee, sewer rates are now calculated using the average monthly winter water consumption (November through February). The methodology places an emphasis on estimating how much water is going down the sewer. Water used during the months of November through February is averaged; during this time, water used for irrigation is at a minimum. To conserve water and save money on your sewer bill, be sure to re-set your irrigation times for fall and winter.
Prepayment Discounts: 6 months 2.63% 12 months 2.77%, Average water use for July/August for a single-family home was 55CCF (100 cubic feet)

<pre>
</div>
</td>
</tr>
</table>
</BODY>
</HTML>
Thanks
ravi

alt131

7:35 pm on Oct 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The recommendations for <pre> allows a user agent to ignore white-space, which ie is choosing to do.
white-space:pre-wrap
(and the proprietory flavours) prevents breaking white-space, so breaks only occur at a new line in the source or as required to fit within a line-box. (Hence "Reducing and Payment' starting on new lines.)
word-wrap:break-word 
breaks a word

Looking at the code, the html <pre> tells the user agents they may ignore breaks, and the css tells them they may only break at a new line in the source, unless breaks are required to fit within a line box, but they may break words if required.

An interesting test - ie 6 & 7 seem to be ignoring the width on the table cell and obeying the "don't break" <pre> and the css, while winSafari, Op9, ff2&3 seem to apply the cell width and apply the "may break" parts of the <pre> and css.

If you want white-space to break so the words wrap remove all the current declarations on <pre> and just set

white-space:normal;
so all browsers behave the same.

.. and don't forget to close the </pre> ;)