What are HTML Elements?
HTML elements are the building blocks of web pages. An HTML element consists of a start tag, content, and an end tag.
Here are some common HTML elements:
1. Heading Elements:
- `<h1>` to `<h6>`: Define headings of different levels.
html
<h1>This is a Heading 1</h1>
<h2>This is a Heading 2</h2>
<!-- ... -->
<h6>This is a Heading 6</h6>
HTML Elements |
2. Paragraph Element:
- `<p>`: Defines a paragraph.
html
<p>This is a paragraph.</p>
3. Anchor Element (Link):
- `<a>`: Creates a hyperlink.
html
<a href="https://www.example.com">Visit Example Website</a>
4. Image Element:
- `<img>`: Embeds an image.
html
<img src="image.jpg" alt="Description of the image">
5. List Elements:
- `<ul>`: Defines an unordered list.
- `<ol>`: Defines an ordered list.
- `<li>`: Defines a list item.
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
</ol>
Difference in HTML Tag and HTML Elements |
6. Table Elements:
- `<table>`: Defines a table.
- `<tr>`: Defines a table row.
- `<th>`: Defines a table header cell.
- `<td>`: Defines a table data cell.
html
<table border="1">
<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>
7. Form Elements:
- `<form>`: Defines an HTML form.
- `<input>`: Defines an input field.
html
<form action="/submit" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<input type="submit" value="Submit">
</form>
8. Div Element:
- `<div>`: Defines a division or a section in an HTML document.
html
<div>
<!-- Content goes here -->
</div>
These elements can be combined and nested to create the structure of a web page. Each element serves a specific purpose, and the combination of elements allows you to create rich and structured content on the web.