0

I have a table created using HTML and Bootstrap 3 like in the following example.

Even if I set a fixed column width through the width attribute in the colgroup this is not applied and I am not able to set a column width at all here.

Can someone tell me if this needs to be done differently when using Bootstrap 3 or if I am missing something else here?
In this case I want to set the column width of a specific column (here the 3rd one) to 70px.

Example table:

<table class="table table-condensed table-responsive tableDT">
    <colgroup>
        <col />
        <col />
        <col width="70px" />
    </colgroup>
    <thead>
        <tr>
            <th>Tag</th>
            <th>No. of Items</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Some text</td>
            <td>Some number</td>
            <td><button type='button' class='btn btn-primary btn-xs'>View</button></td>
        </tr>
    </tbody>
</table>
2
  • 1
    Put the width on the <th> element. The "width" attribute of the <col> element is obsolete. (Better yet, use CSS.) Commented Sep 14, 2014 at 12:44
  • Thanks, this does not seem to make a difference here. Commented Sep 14, 2014 at 12:46

1 Answer 1

1

You do not use 'px'. you just give it as width="70" you can do it in css as well as:

colgroup col:last-child{ width: 70px; }

Sign up to request clarification or add additional context in comments.

1 Comment

That was it - thanks a lot ! Will accept as soon as I can. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.