What is HTML
HTML (Hypertext Markup Language) is the standard language used to create and structure content on the web. It provides the foundation for how webpages are built and displayed in web browsers. HTML uses a series of elements (tags) to organize content into headings, paragraphs, images, links, tables, forms, and more.
Here’s a breakdown of how HTML works:
Basic Structure of an HTML Document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title of the Webpage</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph of text.</p>
<a href="https://www.example.com">This is a link</a>
</body>
</html>
Key Elements of HTML:
- <!DOCTYPE html>: This declares the document type and version of HTML (HTML5 in this case).
- <html>: The root element that contains all HTML code.
- <head>: The section that contains meta-information like the title, character set, and scripts.
- <title>: Defines the title that appears on the browser tab.
- <body>: This is where the visible content of the webpage goes, such as text, images, and links.
- <h1>, <h2>, … <h6>: Heading tags that range from most important (h1) to least important (h6).
- <p>: Paragraph tag for regular text.
- <a>: Link tag to connect to other web pages or URLs.
Example of More Complex HTML:
You can also add tables, images, and forms using HTML:
Example of a Table:
<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>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
Example of an Image:
<img src="image-url.jpg" alt="A description of the image">
What HTML Does:
- Structure: HTML defines the structure of your content. It tells the browser how to arrange text, images, and other media on a page.
- Semantics: HTML elements carry meaning. For example, a
<p>
tag tells the browser that this is a paragraph, while an<h1>
tag tells it that this is the main heading. - Accessibility: Proper HTML improves the accessibility of a website by ensuring that assistive technologies can read the content properly.
In summary, HTML is essential for creating web pages and ensuring they are displayed correctly across different devices and browsers. It’s the backbone of the web!