html_guidelines.rst 1.1 KB

1234567891011121314151617181920
  1. HTML coding guidelines
  2. ======================
  3. We use `Django templates <https://docs.djangoproject.com/en/stable/ref/templates/language/>`_ to author HTML.
  4. Linting HTML
  5. ~~~~~~~~~~~~
  6. We use `curlylint <https://www.curlylint.org/>`_ to lint templates and `djhtml <https://github.com/rtts/djhtml>`_ to format them.
  7. If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``, and format your code by running ``make format``. Alternatively you can also run
  8. ``make lint-client`` for checking and ``make format-client`` for formatting frontend (html/css/js) only files.
  9. Principles
  10. ~~~~~~~~~~
  11. * Write `valid HTML <https://validator.w3.org/nu/>`_. We target the HTML5 doctype.
  12. * Write `semantic HTML <https://html5doctor.com/element-index/>`_.
  13. * Consult `ARIA Authoring Practices <https://w3c.github.io/aria-practices/>`_, in particular `No ARIA is better than Bad ARIA <https://w3c.github.io/aria-practices/#no_aria_better_bad_aria>`_.
  14. * Attach JavaScript behavior with ``data-`` attributes, rather than classes or IDs.
  15. * For comments, use Django templates syntax instead of HTML.