Cant set width of a table column with style option

In cakephp3 how do I set the column width in a table? This style didnt work on the last column ‘Lesson desciption’ with the field name ‘lesson_plan’ below. In cakephp2 the style width worked fine?

<table cellpadding="0" cellspacing="0">
  <thead>
        <tr>
            <th><?= 'id'; ?></th>
            <th><?= 'lesson_date'; ?></th>
            <th><?= 'Tutor _name'; ?></th>
            <th><?= 'Student_name'; ?></th>
            <th><?= 'Subject name'; ?></th>
            <th><?= 'Tutoring Types'; ?></th>
            <th><?= 'Lesson Description
                    (need to complete<br> with 100 chars min)'; ?></th>
      </tr>
    </thead>
      <?php  foreach ($lessons as $key => $item): 
        //foreach ($query3 as $item):
        ?>
        <tr>
            <td><?= $item->id ?></td>
            <td><?= $item->lesson_date ?></td>
            <td><?= $item->tutor->first_name .' '. $item->tutor->last_name ?></td>
          
            <td><?= $item->students[0]->first_name .' '. $item->students[0]->last_name ?></td>
            <td><?= $item->subject->name ?></td>
            <td><?= $item->tutoring_type->value ?></td>
         
            
            <td><?php  echo $this->Form->input($key.'.lesson_plan', ['label'=>'','value'=>$item->lesson_plan ,
                       'style' => 'width: 300px; height:50px;']) ?></td>
        </tr>
        <?php endforeach; ?>

Be aware that you aren’t setting the style on the column, you’re setting it on the input element.

However, if setting the style on the input element is what you are after, then that should do the trick, unless there are any other classes that are overriding it. Perhaps set ‘label’ to false to prevent a label being generated, and post the actual HTML that is generated.

You should look into the generated html (I recommend Chrome developer tools for that) and see whether and where exactly the style attribute is being added. Use the developer tools to tweak the css until it does what you want it to. That usually helps to get to the source of the issue.

Btw: unless you need to dynamically change the with or height of the column, it’s really not recommended to add the css in-line, since it will be applied in every loop iteration, thus resulting in a lot of repeated code.

Simply add it to your css. Keep in mind that you can use selectors like :last-child or custom classes to style your html. That’s much more effecient than adding inline styles.