Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line breaks in html table

How can I stop my table from increasing width every time I insert loooong commentary?

I made a simple example :

<!DOCTYPE html>
<html>
    <body>
        <table width='350'  border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <th id="row_style" bgcolor='#D6D6D6'>ID</th>
                <th id="row_style" width= "50%" bgcolor='#D6D6D6'>Content</th>
                <th id="row_style" bgcolor='#D6D6D6'>Date</th>
            </tr>
            <tr>
                <td id="row_style" bgcolor='#3399FF' scope='col' width='50'>Example</td>td>
                <td id="row_style" width ='10%'> Content</td>td>
                <td id="row_style" bgcolor='#3399FF' scope='col' width ='10%'>Example</td>td>
                <td width ='10%'></td>
            </tr>
        </table>
    </body>
</html>

When I increase the word "content" the table width is increasing.. how can I stop this and insert a line break?

like image 718
Ion Farima Avatar asked Jan 05 '13 21:01

Ion Farima


People also ask

How do you add a line break in HTML table?

Place the line break code <BR> within the text at the point(s) you want the line to break. Notice in the examples below that the line break code can be used in data cells as well as in headers.

How do you break a line in a row in HTML?

The <br> HTML element produces a line break in text (carriage-return).

How do you stop a line break in HTML?

There are several ways to prevent line breaks in content. Using &nbsp; is one way, and works fine between words, but using it between an empty element and some text does not have a well-defined effect. The same would apply to the more logical and more accessible approach where you use an image for an icon.

How do you break a line in HTML without br?

A line break can be added to HTML elements without having to utilize a break return <br> by using pseudo-elements. Pseudo-elements are used to style a specific part of an element. Here we will use ::after to style an HTML element to add a line break.


1 Answers

Sounds terrible but you should use:

<tr><td><br></td></tr>
like image 143
assayag.org Avatar answered Oct 04 '22 04:10

assayag.org