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

Viewed 72

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;
}
2 Answers

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.

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