Home  >  Article  >  Web Front-end  >  How to Make Text Wrap in a TD Element?

How to Make Text Wrap in a TD Element?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-15 11:45:03947browse

How to Make Text Wrap in a TD Element?

Wrap Text in Tag

Problem:

You wish to wrap text within a table cell ( element) but have found that setting style="word-wrap: break-word;" width="15%" does not wrap the text.

Answer:

Wrap TD Text

To effectively wrap text within a element, follow these steps:

  1. Set Table Style:

    table {
        table-layout: fixed;
    }

    This ensures that the table width is fixed, allowing the text to wrap without exceeding the width of the table.

  2. Set TD Style:

    td {
        word-wrap:break-word
    }

    This enables word-wrapping within the table cells.

By following these steps, you can wrap text within elements even with restricted cell widths.

The above is the detailed content of How to Make Text Wrap in a TD Element?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn