HTML – Standardized Practice for Ordering Attributes in HTML Tags

coding-stylehtmlprogramming practices

I am working on an AngularJS project and the attributes are numerous in many of my HTML elements:

  <button type="submit" 
          ng-click="Page.UI.DetailView.ExecuteFunction()" 
          ng-disabled="step5.$invalid" 
          class="btn btn-success pull-right">
      Submit this Product
  </button>

Is there a standardized convention for the order of these attributes? Alphabetical? Grouped by meaning (e.g. all angular attributes together)? Standard HTML attributes ("type" for example) first?

Best Answer

There is no standard. Optimize for ease of understanding, and try to be consistent.

Personally I think it's also good to always put the id attribute first, so that it's easier for testers to find it.