Home > other >  Where is it preferable to specify the width of tables - in HTML or CSS class?
Where is it preferable to specify the width of tables - in HTML or CSS class?

Time:10-15

I read somewhere that the site should be working even without CSS files.

What would be better?

<table width=500>

or

my-table {
   width: 500px;
   min-width: 500px;
}

CodePudding user response:

The width attribute is deprecated for use on a table element. See for example MDN

Deprecated

width This attribute defines the width of the table. Use the CSS width property instead.

CodePudding user response:

Depends on your preference. Do you need the styling to be rendered with the HTML (before the CSS file is loaded).

I would prefer to do it in an external stylesheet, but the above is the only use case I can think of where it makes sense to do it inline.

  • Related