I am using the default, design-time scaffolded view for a list, in an MVC4 Razor app. Each column is as follows:
<td class="col-code">
@Html.DisplayFor(modelItem => item.Code)
</td>
I have tried adding a width attribute to the TD’s, but seems to have no effect. The only thing that works is styling the INPUT rendered by DisplayFor, but I can’t do that here as I have nowhere to set html attributes.
If you are using simple HTML tables, you should add a header to your columns using the
thtag that can then be styled to the desired width.For example:
can be used with this CSS code: