Skip to content

Instantly share code, notes, and snippets.

@calvinjuarez
Created April 20, 2017 22:19
Show Gist options
  • Save calvinjuarez/50120c30978dd168dcd60a8a4dc5b612 to your computer and use it in GitHub Desktop.
Save calvinjuarez/50120c30978dd168dcd60a8a4dc5b612 to your computer and use it in GitHub Desktop.
HTML Attribute Order

Preferred Order of HTML Attributes

When under my control, I like to order HTML attributes in this way.

  1. Identifiers
    • class
    • id
    • type
    • for
    • name
    • rel
  2. HTML-native References
    • href
    • src
    • srcset
    • action
  3. Meta & Content
    • content
    • pattern
    • value
    • placeholder
    • alt
    • title
    • data-* Attributes
  4. Accessibility
    • role
    • aria-* (in a logical order)
    • tabindex
  5. Esoteric Library Attributes (sometimes the placement of these can't be controlled)
    • ng-*
    • data-reactid
  6. Flags
    • checked
    • disabled
    • hidden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment