How to force the maximum table width?

Asked

Viewed 1,459 times

2

Can you set the width to be occupied by the table? forcing it to make a line break and continue when it reaches that maximum width?

1 answer

2


There is, of course, if you want to go straight to HTML:

<table class = "tabela" style = "max-width:100px;">
    <tr>
        <td>teste de tamanho máximo da largura de uma tabela
        </td>
    </tr>
</table>

I put in the Github for future reference.

But the ideal is to have the style referring to the class tabela (in this example, you give the name you want, or you can use a id to identify this specific element) in a separate CSS file.

  • I tried here and it didn’t work, I did a project in php + myslq to take the dice and play on the screen, as there are many, more than 20, it ends up leaking. I used the "for(){}" loop to repeat the snippets that appear, like this: <table border="1" > <? php while($given = $con->fetch_array()){ ? > <tr> <? php for($tel=3; $tel<= 16; $tel++){? > <td>? php echo $given["name"];? ></td> <td><? php echo $given["$tel"];? ></td> <? php } ? > </tr> <? php } ? > </table> Stretching me a little more, this is correct?

  • Did you see it work up there? You should have put all the necessary information in the question, what you really wanted, including this code and possibly the HTML generated by this code, which is much easier to verify. Which by the way doesn’t have what I answered, so it won’t really work.

  • Yes it really works, when I call only 14 phones, when I put more than 14, it keeps leaking, I think my tie is wrong, but thanks anyway :D

  • Try some things that could be done to avoid this but they will cause other worse problems. You can’t put 14 elephants inside a VW Beetle. You can fit 14 dogs but it’s not what you want.

  • Truth... I will study a little more, I started with php a little while, Thank you very much

  • You have no problem with PHP, it’s just HTML (and possibly CSS). Of course, whatever technology it is, whatever maximum knowledge one has, you can’t write the Bible on a piece of paper. It has solutions, but it is something more complex, it goes beyond the scope of the question.

  • I will try to solve this without the <table></table>, if it gives the result I expect, update here :D

  • That’s a great idea, if it’s not a table you’re making, don’t use table.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.