Adjust text length to fit the cell size

Maa -  
 Aiceberg -
Hello,

I would like to adjust the length of the text to fit the dimension of a cell in an HTML table.
Could someone help?
Thanks

Configuration: Android / Chrome 80.0.3987.132

1 answer

  1. Aiceberg
     
    Hello, for all layout work you should use CSS. Tables MUST NOT be used for layout except if they contain tabular data (their contents will not be indexed by search engines as content but as tabular data like a list with rows and columns). That said, if you do have tabular data, here is an example of what you want:
    <html> <head> <!-- in the style tag I put the CSS rule; it is of course more practical to use an external file named for example "style.css" --> <style type="text/css" rel="sylesheet"> td p{ width:100%; text-align:justify; } </style> <!-- a cascade style rule consists of a selector and inside the braces the rules we want to modify, here the selector indicates all p tags contained in a td and the rules indicate that the text (p) must take 100% of the available space (the td cell) and that the text must be justified. The available space therefore depends on the size of the cell. It is also possible to use CSS classes which can be more practical because reusable beyond just a table. For more information train yourself in CSS. --> </head> <body> <table> <tr> <td>titre colonne 1</td> <td>colonne 2</td> <td>colonne 3</td> </tr> <tr> <td><p>contenu col1 ligne1</p></td> <td><p>col2 ligne1</p></td> <td><p>col3 ligne 1</p></td> </tr> <tr> <td><p>contenu col1 ligne1</p></td> <td><p>col2 ligne1</p> </td> <td><p>col3 ligne 1</p></td> </tr> </table> </body> </html>
    CSS is complementary and indispensable to HTML. HTML is used to indicate the hierarchy and nature of the content, and CSS to indicate their appearance and layout. When planning a web page you must therefore separate the content (HTML) from its presentation (CSS). This is why (and also because it is less practical and longer to write) tables should never be used for layout. If it were done, it was more than 15 years ago before the appearance of CSS, which makes writing a page much easier and enables visuals that are much easier to write and allows many more possibilities.
    0