.. _coding_style_frontend: ===================== Frontend coding style ===================== Shortcuts: * :ref:`html` * :ref:`sass` * :ref:`javascript-style` .. _html: HTML ==== Common ------ * Inline style is evil .. code-block:: html

Inline style cannot be cached.
Inline style is difficult to overwrite.
Inline style makes HTML less readable.
Inline style is harder to spot.

* Inline script is evil (except Google Analytics) .. code-block:: html * Style your HTML, don't HTML your style (avoid adding divs for style) .. code-block:: html

... * Variables should be passed using data-attributes as well. They are no excuse for inline script. .. code-block:: html

...
Elements -------- * Avoid the ``id`` attribute, unless there's a good reason. .. code-block:: html
...
* Use `semantic tags`_ like ``
``, ``