7

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.

Community
  • 1
  • 1
lucasrizoli
  • 628
  • 6
  • 14
  • Might potentially be something to ask a high performance expert like http://www.stevesouders.com/blog/ - if you're still curious, that is. – pinkgothic May 25 '11 at 16:27
  • Unrelated, but if you are looking for a standard for ordering the HTML attributes, see this - https://stackoverflow.com/a/69114392/4010017 – kaushalpranav Sep 09 '21 at 08:02

2 Answers2

3

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.

lucasrizoli
  • 628
  • 6
  • 14
cusimar9
  • 5,185
  • 4
  • 24
  • 30
  • 2
    Yeah. The [XML Recommendation states](http://www.w3.org/TR/xml/#sec-starttags) that "the order of attribute specifications… is not significant." – lucasrizoli May 25 '11 at 16:03
2

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

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445