lucasrizoli
lucasrizoli

Reputation: 638

Does the order of HTML attributes have any effect on performance?

Is there any reason that relates to parsing time, layout, rendering time, style application, etc. to have HTML attributes in a certain (or consistent) order?

The order of HTML attributes does not improve a page's compressibility significantly, and maintaining some order can make the markup easier for human readers to figure out (e.g. putting id first, starting <input>s with type, putting boolean attributes at the end of an opening tag) but I'd like to know if there are any performance reasons to consider attribute order.

Upvotes: 8

Views: 2710

Answers (2)

cusimar9
cusimar9

Reputation: 5259

None to speak of I don't think. All the properties within each tag have to be parsed and read before the tag can be properly understood by the browser.

As long as the code is syntax-error free and (obviously) the shorter the better.

Upvotes: 3

Daniel A. White
Daniel A. White

Reputation: 191058

It all depends on the layout engine, but i suspect it would be negligible. You should not be concerned with this.

Upvotes: 2

Related Questions