HTML Basics: Exploring Essential Tags with Examples and Usage
Introduction: HTML (Hypertext Markup Language) is the backbone of the web, serving as the standard markup language for creating and structuring webpages. Understanding the fundamental HTML tags and their usage is essential for any aspiring web developer. In this blog, we will explore the basics of HTML, discuss important tags, provide example code, and explain their usage in building web content.
- HTML Document Structure: Every HTML document begins with a declaration and is structured using the following essential tags:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
<!DOCTYPE html>
: Declares the document type and version.<html>
: Represents the root element of an HTML document.<head>
: Contains metadata and document information.<title>
: Sets the title displayed in the browser's title bar.<body>
: Encloses the visible content of the webpage.
- Heading and Paragraph Tags: HTML provides tags for creating headings and paragraphs:
<h1>Heading 1</h1>
<p>This is a paragraph.</p>
<h1>
to<h6>
: Represents headings of different levels (from largest to smallest).<p>
: Defines a paragraph of text.
- Hyperlinks: Hyperlinks enable navigation between webpages:
<a href="https://www.example.com">Visit Example.com</a>
<a href="url">
: Creates a hyperlink to the specified URL.
- Images: Displaying images on webpages is achieved using the
<img>
tag:
<img src="image.jpg" alt="Description of Image" width="300" height="200">
<img src="url" alt="description">
: Embeds an image into the webpage.src
: Specifies the image URL.alt
: Provides alternative text for the image (useful for accessibility).width
andheight
: Sets the dimensions of the image in pixels.
- Lists: HTML supports ordered and unordered lists:
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
</ol>
<ul>
: Creates an unordered (bulleted) list.<ol>
: Generates an ordered (numbered) list.<li>
: Defines each list item.
- Tables: Tables organize data into rows and columns:
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
</tr>
</table>
<table>
: Represents a table.<tr>
: Defines a table row.<th>
: Specifies a table header cell.<td>
: Represents a table data cell.
- Forms: Forms collect user input and enable interactions:
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br>
<input type="submit" value="Submit">
</form>
<form action="url" method="httpMethod">
: Creates a form for data submission.<label for="id">
: Associates a label with a form control.<input type="text">
: Generates a text input field.<br>
: Inserts a line break.<input type="submit">
: Creates a submit button.
Conclusion: Understanding the fundamentals of HTML is essential for creating websites. You may develop well-structured and compelling online content by learning and utilising fundamental HTML tags, such as those described in this article. To improve your web development abilities, try with different tags and discover advanced HTML principles. You'll be well on your way to designing distinctive webpages that amaze recruiters and users alike if you have a good foundation in HTML.