how to get fixed table columns width


Tags: html,css,table,width

Problem :

How do you make individual table columns fixed for a certain width so no matter how much text is in that column, the width of the column stays the same?

<col> tag is only good for firefox

table-layout:fixed is for whole table really

Just setting a width does not do it

what is the best css property to use for this

Below is code:

    .video{
        overflow:hidden;
        table-layout:fixed;
        max-width:146px;
                }
            .audio{
        overflow:hidden;
        table-layout:fixed;
        max-width:146px;
                }
            .image{
        overflow:hidden;
        table-layout:fixed;
        max-width:146px;
                }
             .qid2{
        overflow:hidden;
        table-layout:fixed;
        max-width:92px;
                }

  <table border=1 id="vidtbl">
    <tr>
    <th>Question No</th>
    <th>Video</th>
    <th>Audio</th>
    <th>Image</th>
    </tr>
    <tr>
    <td class="qid2"></td>
    <td class="video">images/dolphinvideo.png//////////////////////////////////////</td>
    <td class="audio">hello</td>
    <td class="image"></td>
    </tr>
    </table>


Solution :

try using

max-width:100px;

or

max-height:100px;

This will let your column expand maximum upto the width you set.


    CSS Howto..

    FontAwesome icon showing as black box. What CSS is needed to display icon?

    How do I align text to the middle of an element with CSS in Twitter Bootstrap?

    HTML CSS: How to align grid to content area?

    how to copy font-family from a webpage

    How to size relative div which haven't a content?

    How to avoid overlapping text using CSS?

    How can I have a CSS style different for IE6?

    how to allow transform in htmlpurifier

    How do i include font awesome classes in my css file?

    How to scroll with large pages with jQuery onepage-scroll plugin?

    How is does Jquery display a tooltip on this span element?

    How to set position of checkbox to middle of td and input type text using css? [duplicate]

    CSS how to align elements inside a div with 2 columns

    how to make animate.css(plugin) work instantly on live site load?

    How to swap class / id using jquery in a css list?

    how to switch between left and right css rules using Jquery?

    How to keep sub div from considering height of its cousin?

    how to change a css class style through javascript?

    How can I make this kind of a border?

    how to add several td and tr in css

    How make something like Facebook Notifications?

    How can I use CSS to vertically center the text in an anchor, within a LI?

    How to get the authored style properties of an element?

    How to get hoverover text to be at the same line-height as the triggering text

    how to select a class which is children of many elements

    How to break a line after some certain width in css

    CSS Horizontal Menu is showing list bullets

    How to conditionally load CSS

    HTML/CSS showing buttons online and auto going to next line

    How can i make the horizontal navigation menu center aligned