Skip to content

Category · 1 tool · 1 guide

HTML, CSS and JavaScript tools

HTML, CSS and JavaScript are the three languages every web developer touches, whatever framework they use. Even in a React or Vue project, you regularly deal with raw markup: email templates, CMS exports, server-rendered pages, snippets copied from documentation and the minified source of a page you are debugging.

Unformatted front-end code is hard to work with. Deeply nested markup on one line hides unclosed tags and misplaced attributes, and inline styles and scripts blur together. Formatting it is not as simple as adding line breaks, though: in HTML, whitespace between inline elements is significant, and a careless formatter can add gaps between links or buttons that were not there before.

The tools in this category use Prettier, the formatter most front-end teams already run in their editors and CI, so the output matches what your project produces. Embedded CSS and JavaScript are formatted too, and all processing happens in your browser.

Tools in this category

Common tasks

Key concepts

Whitespace sensitivity
Browsers collapse runs of spaces and line breaks into one space between inline elements. Adding or removing a line break between two links can therefore add or remove a visible gap.
Void elements
Elements such as br, img, input and meta have no closing tag. Writing <br/> is allowed in HTML5, but the slash has no effect.
Semantic HTML
Using elements for their meaning, like nav, main, button and h1 to h6, instead of generic divs. It improves accessibility, SEO and keyboard support with no extra code.
Prettier
An opinionated code formatter with very few options. Teams adopt it to end style debates: code is reformatted automatically on save or in CI.
Minification
Removing whitespace, comments and long names to shrink files for production. It is done by build tools, and source maps let you debug the original code.

Best practices

  1. Run the same formatter in editors and CI so committed code always has one style.
  2. Keep whitespace-sensitive formatting on unless you know the markup has no inline elements; ignoring whitespace can change rendering.
  3. Use semantic elements and real buttons and links before reaching for ARIA attributes.
  4. Keep CSS and JavaScript in separate files for anything more than a small snippet, so they can be cached and linted.
  5. Never format minified production bundles to edit them; fix the source and rebuild.

Guides