The Elements are the building blocks of HTML documents and consist of a start tag, content, and an end tag.
Here's a basic example:
<p> is the start tag.
This is a paragraph is the content.
</p> is the end tag.
This example creates a simple webpage with a header, navigation menu, two sections, and a footer. The content inside each section is just placeholder text and can be replaced with actual content.
<div>
<h1>This is a heading</h1>
<p>This is a paragraph inside a div.</p>
</div>
In this example, the <h1> (heading) and <p> (paragraph) elements are nested within the <div> (division) element.
It's important to always include the end tag for HTML elements, except for certain elements that are intentionally designed to be self-closing (discussed later). Skipping the end tag can lead to unexpected behavior and errors.
For example:
<p>This is a paragraph without an end tag
This is incorrect and may cause issues. Always close tags properly:
<p>This is a paragraph with the correct end tag</p>
Some HTML elements are empty, meaning they don't have any content and don't require an end tag. These are usually self-closing tags. For example, the line break <br> and image <img> tags:
<p>This is a paragraph.<br>This is a new line.</p>
<img src="image.jpg" alt="An example image" >
HTML is not case-sensitive, meaning you can use uppercase or lowercase letters for tags and attributes. However, it's a widely adopted convention to use lowercase for HTML tags and attributes.
For Example:
<P>This is a paragraph using uppercase tags</P>
This is valid but not commonly practiced. It's recommended to stick to lowercase for consistency and better readability:
<p>This is a paragraph using lowercase tags</p>
© Copyright Sahad Sarang 2024