HTML Formatter
Run Prettier over HTML, with the parser already selected on this page.
HTML is the hardest case Prettier handles, because in HTML whitespace is sometimes significant and reformatting can change rendering.
Whitespace sensitivity
Inline elements are whitespace-sensitive: a space between two spans is a rendered space, and removing it changes the page. Prettier tracks each element display type and avoids reformatting where it would alter output, which is why HTML formatting sometimes looks less tidy than you expect.
A pre or textarea block is left alone entirely, since every character inside it is meaningful.
Attributes wrap all or nothing
Attributes stay on one line while they fit within the print width and go one per line once they do not. There is no partial wrapping, so a single long class attribute can explode the whole tag.
Embedded CSS and JavaScript
Prettier formats the contents of style and script blocks with the matching parser, so a page with inline styling and inline script comes out consistent throughout rather than only in its markup.
Template syntax from a server-side language is a different matter. Handlebars, Jinja and ERB constructs are not HTML, and Prettier will either leave them alone or, in awkward cases, refuse to parse the file. Format the template as its own language where a plugin exists.
Self-closing tags and void elements
Void elements such as img, br and input have no closing tag, and Prettier writes them without a trailing slash in plain HTML because the slash is meaningless there.
In JSX and Vue templates the slash is required, which is one of several reasons the parser selection matters rather than being cosmetic.