HTML (HyperText Markup Language) is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as CSS (Cascading Style Sheets) and JavaScript.
HTML Structure
The basic structure of an HTML document is as follows:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
declaration helps with browser compatibility.<html>
element is the root element of an HTML page.<head>
element contains meta-information about the document.<title>
element specifies a title for the document.<body>
element contains the content of the document, such as text, images, links, etc.
Elements and Attributes
Elements
HTML elements are defined by tags, such as <h1>
for headings and <p>
for paragraphs.
Attributes
Attributes provide additional information about elements. For example, the <a>
tag can have an href
attribute to specify the URL of the link.
<a href="https://www.example.com">Link Text</a>
Images
To add an image to your HTML document, use the <img>
tag.
<img src="image.jpg" alt="Image description">
You can also add a title attribute to provide additional information about the image.
<img src="image.jpg" alt="Image description" title="Additional information">
Links
HTML links are defined with the <a>
tag.
<a href="https://www.example.com">Link Text</a>
The href
attribute specifies the URL of the page the link goes to.
Navigation Bar
A navigation bar is a set of links that help users navigate through a website.
<nav>
<ul>
<li><a href="/home">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
Tables
HTML tables are defined with the <table>
, <tr>
, <th>
, and <td>
tags.
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
</table>
Forms
HTML forms are used to collect user input.
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
The action
attribute specifies the URL where the form data will be sent, and the method
attribute specifies the HTTP method (GET or POST).
Learn More
For more information about HTML, visit our HTML tutorial.