Julian M. Julian M. - 5 months ago 10
CSS Question

How to change the width of a HTML table?

I am declaring a table this way:

<div class="row">
<div class="module span12">
<section class="module">
<table class="table table-striped table-bordered table-condensed">

echo "<tr><td style='color: white; background-color: black;'><strong>Overall inventory breakdown</strong></td>";
echo "<td style='text-align: center; color: white; background-color: black;'><strong></strong></td>";
echo "<td style='text-align: center; color: white; background-color: black;'><strong>Ist</strong></td>";
echo "<td style='text-align: center; color: white; background-color: black;'><strong>Soll</strong></td></tr>";

</table>
</section>
</div>
</div>


Right now, the table is as wide as the entire page. But I want it to be smaller.

I already tried with several CSS variations, such as set
width
value on each
td
, but nothing works for me. Any help?

Answer

This appears to be a Bootstrap question.

.table {
    /* width: 100%; */
    width: auto;
}

Get to know your browser's document inspection tool. It makes discovering the source of things like this trivial.