table alignment

table alignment

almalm Posts: 2Questions: 1Answers: 0

Hi, a simple question from a beginner.
Everything works, but I'd like the tables not to span across the whole screen. My tables are quite thin, and the default is for the table to spread across the entire width of the screen. If I put a "width=20%" in the

<

table> tag, the table is much more compact, but it places it in the middle of the page, with large white spaces on either side.

Ideally I'd like to
1. align the table on the left (or right) hand side of the screen, and
2. let it decide how wide the columns should be, i.e. just make the columns as wide as they need to be for the given data. (This is the default for bland untouched

<

table>s
Thanks
Alm

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @alm,

    If you put the table into a div container and make that 20%, with the table filling 100% of that, you should be fine.

    Cheers,

    Colin

  • almalm Posts: 2Questions: 1Answers: 0

    Hi @colin
    Thanks for the solution. It solves my first problem (aligning the table left or right) but doesn't solve my second problem, i.e. the table spreading over the default width (100%) or and specific width I give it.

    Sometimes table X has all cells populated so it makes sense to use 100% of the space available. Sometimes table X is sparsely populated and requires just a portion of the space available. Is there a way to achieve this?

    Thanks
    Alm

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    Can you give me a link to a page showing the issue so I can fully understand the problem please? It might be something that is resolvable with a simple margin: 0 auto; but I'm not certain.

    Allan

This discussion has been closed.