HTML Cheat Sheet


<html> - Root of the document

Defines the root of an HTML document.

<html>

   <!-- content goes here -->

</html>

<head> - Contains metadata

Holds metadata about the document, like title and links to stylesheets.

<head>

   <title>Page Title</title>

</head>

<body> - Visible page content

Contains all the content visible on the webpage.

<body>

   <h1>Hello World</h1>

</body>

<h1>-<h6> - Headings

Defines headings from largest (<h1>) to smallest (<h6>).

<h1>Main Heading</h1>
<h2>Subheading</h2>

<p> - Paragraph text

Defines a paragraph of text.

<p>This is a paragraph.</p>

<a> - Hyperlink

Creates a hyperlink to another page or location.

<a href="https://example.com"> Example </a>

<img> - Displays images

Shows an image on the page.

<img src="image.jpg" alt="Description">

<ul> - Unordered list

Creates a list with bullet points.

<ul>

   <li>Item 1</li> 
<li>Item 2</li>

</ul>

<ol> - Ordered list

Creates a numbered list.

<ol>

     <li>First item</li>
<li>Second item</li>

</ol>

<li> - List item

Defines a single item in a list.

<li>Item text</li>

<div> - Block container

Used to group block-level elements for styling or layout.

<div>

    <p>Content inside a div.</p> 

</div>

<span> - Inline container

Used to group inline elements for styling.

<span> Inline text </span>

<table> - Creates table

Defines a table with rows and cells.

<table>

  <tr> 
<td>Cell 1</td>
<td>Cell 2</td>
</tr>

</table>

<form> - User input form

Allows users to submit input to a server.

<form action="/submit" method="post">

   <input type="text" name="name"> 
<button type="submit">Submit
</button>

</form>

<input> - Input field

Creates a field for user input.

<input type="text" name="username">

<button> - Clickable button

Defines a clickable button.

<button type="button">Click Me</button>