<pre>, <textarea>, <script> and <style> content is kept intact.
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.
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>
| Tag | Purpose | Example |
|---|---|---|
<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> |
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">
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.