1

I have an issue. I have tried the style 'table style="width:200px!important;"' as inline but still somehow table is of 742 px what could be the reason of it as we know inline important override all other styles. in td I am just printing 1,2,3 garbage smallest values but still no luck.

   <strong><span><?php echo $this->__($this->getHeader()) ?></span></strong>

    <?php $products = $this->getCollection(); ?>
    <?php if (0 < $products->getSize()) { ?>
        <table style="width:200px !important;">

            <tr>
                <?php 
                $i=0;
                foreach ($products as $p) { ?>
                    <td style="text-align:left;">                        
                        1                        
                    </td>
                <?php } ?>
            </tr>


        </table>
    <?php } ?>
3
  • 2
    can you provide little bit more code or fiddle or something? Commented Nov 3, 2015 at 10:46
  • Please see sscce.org — A good code example would be pure HTML with the minimum number of rows to reproduce the problem. It wouldn't include any PHP since that doesn't have any effect on the rendering in the browser. Commented Nov 3, 2015 at 10:48
  • Can you share the resulting html code ? How many columns are there ? Commented Nov 3, 2015 at 10:51

1 Answer 1

3

!important will force the value of that property to be 200px.

It won't force the table to conform to that width.

The default table layout model is auto and will adapt the table to fit its contents, no matter what width you specify.

If the 'table' or 'inline-table' element has 'width: auto', the used width is the greater of the table's containing block width, CAPMIN, and MIN.

You need to switch to the fixed layout model if you want to lock a table width below its natural width.

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

Comments

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.