HTML Formatter & Preview

Beautify or minify HTML code and see the rendered result instantly in your browser.
HTML Source 0 characters
Result 0 characters
Live Preview
Format adds indentation and line breaks without changing how the page renders. Minify removes HTML comments and unnecessary whitespace to reduce file size. <pre>, <textarea>, <script> and <style> content is kept intact.
The preview runs in a sandboxed iframe and scripts are blocked by default. Only enable “Allow scripts” for HTML you trust.
All work is done in your browser; your HTML is never uploaded.


Update:
Add HTML formatter with live preview (2026-12-02)
Add a beginner HTML tutorial to the instructions (2026-12-02)
HTML Basics - A Quick Starter Guide
1. What is HTML?

HTML (HyperText Markup Language) describes the structure of a web page using elements. Most elements have an opening tag, some content and a closing tag, for example <p>Hello world</p>. Empty elements such as <br> and <img> have no closing tag.

2. A minimal HTML page

Every page starts with a document type declaration and an <html> root element. The <head> holds information about the page, while <body> holds what visitors see.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My First Page</title>
</head>
<body>
    <h1>Hello!</h1>
    <p>This is my first paragraph.</p>
</body>
</html>
3. Commonly used tags
TagPurposeExample
<h1> - <h6>Headings, from most to least important<h2>Title</h2>
<p>A paragraph of text<p>Some text</p>
<a>A link to another page<a href="https://officetool.online">Website</a>
<img>An image (empty element)<img src="logo.png" alt="Logo">
<ul>, <ol>, <li>Unordered and ordered lists<ul><li>Item</li></ul>
<div>, <span>Containers used for layout and styling<div class="box">...</div>
<table>Tabular data with rows and cells<table><tr><td>A</td></tr></table>
<br>, <hr>A line break and a horizontal rule<br>, <hr>
4. Attributes

Attributes add extra information to an opening tag and are written as name="value". Common ones are class and id for styling, href for links, src and alt for images, and style for inline CSS:

<p class="intro" id="first">Welcome</p>
<a href="https://officetool.online/" target="_blank">Open in a new tab</a>
<img src="photo.jpg" alt="A photo" width="200">
5. Nesting rules

Elements must be closed in the reverse order in which they were opened, and tags must not overlap. Wrong nesting can make browsers render the page differently than you expect.

<!-- Correct -->
<strong>This is <em>important</em></strong>

<!-- Wrong -->
<strong>This is <em>important</strong></em>

Try it: paste any of the examples above into the HTML Source box, then use Format or Minify and check the result in the live preview.