Summary of mandatory line breaks on pages

Source: Internet
Author: User
If you want a table to be fixed in size, the text inside will be forcibly wrapped (especially when a long string of English text is separated by spaces ), the style: Table-layout: fixed. However, there will be some problems in Firefox. Refer to some Gmail practices and perform several tests to find a solution.

If you want a table to be fixed in size, the text inside will be forcibly wrapped (especially when a long string of English text is separated by spaces ), the style: Table-layout: fixed. However, there will be some problems in Firefox. Refer to some Gmail practices and perform several tests to find a solution.

Example 1: (IE browser) General situation

 
<Table border = 1 width = 80>
<Tr>
<TD> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>

Effect:
We can see that width = 80 does not work, and the table is opened by characters.

Example 2: (IE browser) use the style table-layout: fixed

 
<Style>
. TBL {table-layout: Fixed}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>

Effect:
Width = 80 takes effect, but the table line breaks.

Example 3: (IE browser) use the style table-layout: fixed and nowrap

 
<Style>
. TBL {table-layout: Fixed}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>

Effect:
Width = 80 takes effect, and line feed is also killed.

Example 4: (IE browser) use the style table-layout: fixed and nowrap when the value is fixed to the TD size.

 
<Style>
. TBL {table-layout: Fixed}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 20 nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>

Effect:
Unfortunately, nowrap of the first td does not work.

Example 5: (IE browser) use the style table-layout: fixed and nowrap when the percentage is fixed to the TD size.

<Style>
. TBL {table-layout: Fixed}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 25% nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>

Effect:

Change to percentage, and finally get it done

Example 6: (Firefox browser) use the style table-layout: fixed and nowrap when the percentage of TD size is fixed
Effect:
Put Example 5 under Firefox, and FT again

Example 7: (Firefox browser) use the style table-layout: fixed and nowrap when the percentage is fixed to the TD size, and use the DIV

<Style>
. TBL {table-layout: Fixed}
. TD {overflow: hidden ;}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 25% class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
<TD class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
</Tr>
</Table>

Effect:
The world is finally peaceful

Example 8: (Firefox browser) use the style table-layout: fixed and nowrap when the value is fixed to the TD size, and use the DIV

<Style>
. TBL {table-layout: Fixed}
. TD {overflow: hidden ;}
</Style>

<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 20 class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
<TD class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
</Tr>
</Table>

Effect:
Nowrap does not work anymore.

In the end, Example 7 is a solution that can perfectly solve the page force Line Break Problem in IE and Firefox.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.