HTML attributes Order

Attribute order

HTML attributes should come in this particular order for easier reading of code.
  • class
  • id, name
  • data-*
  • src, for, type, href, value
  • title, alt
  • role, aria-*
Classes make for great reusable components, so they come first. Ids are more specific and should be used sparingly (e.g., for in-page bookmarks), so they come second.


FROM http://codeguide.co/#html-attribute-order

留言

這個網誌中的熱門文章

[java]半型轉全型

[API Server]jersey 檔案上傳

[javascript]當月第一天、當月最後一天