A typical HTML document consists of three main sections:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is where I’ll share my learning journey.</p>
</body>
</html>
Output:-
Explanation of Key Sections:
DOCTYPE Declaration: Declares the document as HTML5.
HTML Element: The root element wrapping all content.
Head Section: Contains metadata like the title and linked stylesheets.
Body Section: Contains visible content like headings, paragraphs, images, and more.
---
3. HTML Tags and Their Uses
a. Headings:
Define the structure of your content with headings. They range from <h1> (largest) to <h6> (smallest).
<h1>Main Title</h1>
<h2>Subheading</h2>
<h3>Smaller Heading</h3>
b. Paragraphs:
Use <p> for adding text blocks.
<p>This is a paragraph explaining a concept.</p>
c. Links:
Create hyperlinks using the <a> tag. Include the href attribute for the URL.
<a href="https://www.google.com" target="_blank">Visit Google</a>
target="_blank" ensures the link opens in a new tab.
d. Images:
Embed images using the <img> tag.
<img src="image.jpg" alt="Description of the image" width="500">
Always use the alt attribute for accessibility and SEO.
e. Lists:
Organize content with ordered and unordered lists.
Unordered List:
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
Ordered List:
<ol>
<li>Step 1: Learn HTML.</li>
<li>Step 2: Practice daily.</li>
<li>Step 3: Build projects.</li>
</ol>
---
4. Advanced HTML Concepts
a. Tables
Display data in rows and columns with <table>.
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
</tr>
</table>
b. Forms
Collect user input with <form> elements.
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
c. Comments
Add notes in your code that won’t appear in the browser.
<!-- This is a comment -->
---
5. Tips for Writing Clean HTML
Use Proper Indentation: Makes code readable and easier to debug.
Close All Tags: Ensure every opening tag has a corresponding closing tag.
Validate Your Code: Use tools like W3C Validator to check for errors.
---
6. Practice Exercises
Beginner Exercise:
1. Create a webpage with:
A title: "Learning HTML Basics."
A heading: "HTML is Fun!"
A paragraph describing your favorite subject.
A link to a resource you find helpful.
Advanced Exercise:
2. Create a webpage with:
A navigation bar using an unordered list.
A table listing your daily schedule.
An image with a caption.
---
7. Frequently Asked Questions
Q: Do I need any tools to start with HTML?
No special tools are required. You can start with a simple text editor like Notepad (Windows) or TextEdit (Mac). For advanced editing, use Visual Studio Code or Sublime Text.
Q: Is HTML enough to build a complete website?
HTML structures the content, but you’ll need CSS for design and JavaScript for interactivity.
---
Conclusion
HTML is the first step in your web development journey. By mastering its basics, you’ll build a strong foundation for creating professional websites. Keep practicing and experimenting with different tags to enhance your skills!
---
Comments