Skip to content

Instantly share code, notes, and snippets.

@sushant-j
Last active February 13, 2017 12:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sushant-j/9d9599b4fb4c825ad7611484bb82c4fc to your computer and use it in GitHub Desktop.
Save sushant-j/9d9599b4fb4c825ad7611484bb82c4fc to your computer and use it in GitHub Desktop.
Coding standards and guidelines for HTML files.

HTML Code Standards

1. HTML Attribute Ordering

HTML element attributes _must_ appear in following order:

HTML Native

  1. class
  • id, name
  • data-*
  • src, for, type, href, value,
  • title, alt
  • rol, aria-*

Angular stuff

  1. ng-class
  • ng-init,
  • ng-model
  • ng-click
  • ng-if, ng-hide, ng-show
  • custom-directives
  • ng-disabled

Boolean Attributes

  1. required, disabled, etc.

2. HTML Self-closing elements 1

  • For these, omit the / at the end of the tag.

    area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr

3. <img> should have alt attribute

References

1http://www.colorglare.com/2014/02/03/to-close-or-not-to-close.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment