Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force two elements to always stay on the same line in a <td>

Tags:

html

css

The code is pretty simple:

<table id="tabel_user" style="width: 100%; border: 0; background-color: white;" cellpadding="0" cellspacing="0"> <tr>     <td style="border: 0; padding: 0; padding-left: 5px;">         <label for="abcd"><input class="check_useri" id="abcd" name="abcd" type="checkbox" /> abcd </label>     </td> </tr> </table>  

They stay neatly on the same line unless the text in the label gets really long and the table needs to stretch to accomodate it, then the text sometimes gets forced below the checkbox. How can I stop it from doing that?

like image 826
Bogdan Avatar asked Apr 04 '12 09:04

Bogdan


People also ask

How do you keep two elements on the same line?

To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.

How do I force HTML elements to stay on the same line?

You can force the content of the HTML <div> element stay on the same line by using a little CSS. Use the overflow property, as well as the white-space property set to “nowrap”.

How do I keep my div on the same line?

Set size and make inline Because they're block elements, when reducing the size of Div one to make room for the other div, you're left with space next to Div one and Div two below Div one. To move the div up to the next line both div's need to have the inline-block display setting as shown below.


1 Answers

You can force inline elements to stay on the same line using the CSS property white-space:

<td style="white-space:nowrap;">   this content will not be wrapped </td> 
like image 139
Lukas Eder Avatar answered Oct 09 '22 03:10

Lukas Eder