What are HTML Tags?
HTML (Hypertext Markup Language) uses tags to structure content on the web. Tags are enclosed in angle brackets and come in pairs – an opening tag and a closing tag.
Here are some commonly used HTML tags:
1. Document Structure:
- `<html>`: Defines the root of an HTML document.
- `<head>`: Contains metadata about the HTML document.
- `<title>`: Sets the title of the HTML document.
- `<body>`: Contains the content of the HTML document.
html
<!DOCTYPE html>
<html>
<head>
<title>My HTML Document</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
HTML Tags |
2. Headings:
- `<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>
3. Paragraphs:
- `<p>`: Defines a paragraph.
html
<p>This is a paragraph.</p>
4. Links:
- `<a>`: Creates a hyperlink.
html
<a href="https://www.example.com">Visit Example Website</a>
5. Lists:
- `<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>
6. Images:
- `<img>`: Embeds an image.
html
<img src="image.jpg" alt="Description of the image">
7. Forms:
- `<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. Tables:
- `<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>
These are just a few examples, and there are many more HTML tags for various purposes. The use of tags allows you to structure and format content on web pages.