HTML style guide
This style guide defines Magento internal requirements for HTML code style for teams that develop LESS and CSS code. We recommend that developers who create Magento extensions and customizations also use these standards.
The guide is based on the Google HTML/CSS Style Guide with certain modifications that are described further.
Use only spaces for indentation:
- Tab size: 4 spaces
- Indent size: 4 spaces
- Continuation indent: 4 spaces
End of file
Add a blank line at the end of file.
Always close self-closing tags.
Avoid code lines longer than 120 characters. When using an editor, it is inconvenient to scroll right and left to read the HTML code. Align tag attributes one under another to increase code readability.
Spaces around equals sign (“=”)
Spaces around equals sign (“=”) are acceptable, but not recommended. The code without spaces is easier to read.
Spaces and colon in attributes
Use no space before the colon and one space after the colon for the sake of readability.
Use appropriate HTML5 elements for blocks. The following diagram shows how to define which HTML5 element to use for a block:
Use semantic class names and IDs. Avoid presentational class names.
All pages should comply with the Web Content Accessibility Guidelines (WCAG) 2.0.
All crucial pages (like product page) should contain microdata. Please pay attention to this recommendation when adding new functionality.