Html Style Guide

Anchor

External links must have rel="noopener" and target="_blank" attribute.

// Bad 
<a href="path/to/external/file">External URL</a>

// Good 
<a href="path/to/external/file" rel="noopener" target="_blank">External URL</a>

Title attribute

Anchor must have title attribute.

// Bad
<a href="#">Link</a>

// Good
<a href="#" title="Description of anchor">Link</a>

Attribute

Attribute Case

Attribute must be written in lowercase.

Attribute value

Attribute value must be wrapped in quotation marks.

Boolean attribute

Boolean attribute values like checked, disabled and required are redundant and must be omitted.

Equal Sign

Spaces around attribute equal signs must be avoided.

Work with css

BEM, or “Block-Element-Modifier”, is a naming convention for classes in HTML and CSS. It was originally developed by Yandex with large codebases and scalability in mind, and can serve as a solid set of guidelines for implementing OOCSS.

We recommend a variant of BEM with PascalCased “blocks”, which works particularly well when combined with components (e.g. React). Underscores and dashes are still used for modifiers and children.

Example :

JavaScript hooks

Avoid binding to the same class in both your CSS and JavaScript. Conflating the two often leads to, at a minimum, time wasted during refactoring when a developer must cross-reference each class they are changing, and at its worst, developers being afraid to make changes for fear of breaking functionality.

We recommend creating JavaScript-specific classes to bind to, prefixed with .js-:

Reference:

Last updated