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

How to Make Text Wrap in a TD Element?

Mary-Kate Olsen
Release: 2024-11-15 11:45:03
Original
1008 people have browsed it

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;
    }
    Copy after login

    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
    }
    Copy after login

    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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template