Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best attributes order in HTML for DOM queries

Is there an order of attributes which make the DOM queries faster? For example in the beginning\end of the element.

When I traverse the DOM up will it be better to put the attributes in the end and the other way around when I traverse the DOM down?

like image 715
gdoron is supporting Monica Avatar asked Apr 23 '12 14:04

gdoron is supporting Monica


1 Answers

No, the browser parses the HTML and constructs the DOM. At that point the literal source of the page is not important anymore, thus DOM queries are not effected by the order.

However I personally like to put my id first, then class, then anything else. For readability.

like image 100
zeel Avatar answered Sep 17 '22 11:09

zeel