HTML structure, elements, attributes, and the document tree
HTML (HyperText Markup Language) is the skeleton of every webpage. An HTML document is a tree of elements, each defined by an opening tag, optional content, and a closing tag: <p>text</p>. Elements can carry attributes that modify their behaviour, href on <a>, src on <img>, class and id on almost anything. Indentation in HTML is cosmetic, browsers ignore it, but consistent 2- or 4-space indentation is what makes nested elements readable during development and code review. Minified HTML collapses that whitespace to reduce transfer size; formatted HTML restores the hierarchy for human inspection.
Most common formatting problems come from deeply nested structures: a <table> inside a <div> inside a <section> inside a <main> quickly becomes illegible without consistent indentation. Paste minified HTML from a template engine, a CMS export, or a bundler output here and click Format to restore readable structure before editing or debugging.
| Element type | Examples | Notes |
|---|---|---|
| Void elements | <br>, <hr>, <img>, <input>, <meta>, <link> | No closing tag; self-closing in HTML5 |
| Block elements | <div>, <p>, <section>, <article>, <h1–h6> | Start on new line; take full width |
| Inline elements | <span>, <a>, <strong>, <em>, <code> | Flow inside text; don't break line |
| Semantic elements | <nav>, <main>, <header>, <footer>, <aside> | Carry meaning for accessibility and SEO |
Common HTML syntax errors the formatter catches
The formatter preserves HTML structure but visually surfaces structural issues: unclosed tags (a <div> without a matching </div> will indent everything after it at the wrong level), incorrect nesting (block elements inside inline elements like <span><div>), and missing or mismatched quotes around attribute values. Browsers are forgiving and display malformed HTML anyway, which hides these problems until they cause layout or accessibility bugs in edge cases.
Related: CSS formatter for stylesheets, JavaScript formatter for scripts. See the CI/CD guide for HTML linting in build pipelines.