Html Style Guide
Anchor
External links
External links must have rel="noopener"
and target="_blank"
attribute.
Title attribute
Anchor must have title
attribute.
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.
CSS Trick's BEM 101
Harry Roberts' introduction to BEM
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