Learn HTML Tags | AsgarTech
HTML Tags - AsgarTech
HTML tags are used to structure and format the content of web pages. Here are some common HTML tags with code examples:
- Heading Tags:
<h1>This is a Heading 1</h1>
<h2>This is a Heading 2</h2>
<h3>This is a Heading 3</h3>
<h4>This is a Heading 4</h4>
<h5>This is a Heading 5</h5>
<h6>This is a Heading 6</h6>
- Paragraph Tag:
<p>This is a paragraph.</p>
- Image Tag:
<img src="image.jpg" alt="Alternative Text">
- Anchor Tag:
<a href="https://www.example.com">Link Text</a>
- List Tags:
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
- Table Tag:
<table>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
- Form Tag:
<form action="/submit-form" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="submit" value="Submit">
</form>
HTML (Hypertext Markup Language) elements are the building blocks of web pages. They define the structure and content of the web page. An HTML element consists of a start tag, content, and an end tag. The start tag and end tag are enclosed in angle brackets < >, and the content is the text or other elements that come between them. Here's an example of an HTML element:
- <p>This is a paragraph element</p>
In this example, <p> is the start tag, and </p> is the end tag, and "This is a paragraph element" is the content of the paragraph element.
- <div>
- <h1>Heading 1</h1>
- <p>This is a paragraph element inside a div element</p>
- </div>
In this example, the <div> element contains a <h1> element and a <p> element.
HTML elements also have attributes, which provide additional information about the element. Attributes are specified in the start tag, and they have a name and a value separated by an equals sign. Here's an example of an HTML element with an attribute:
- <img src="image.jpg" alt="Alternative Text">
In this example, the <img> element has two attributes: src and alt. The src attribute specifies the source URL of the image, and the alt attribute provides alternative text for the image in case it cannot be displayed.
HTML elements can also have self-closing tags for elements that do not have any content, such as the <img> tag. Here's an example of a self-closing tag:
- <img src="image.jpg" alt="Alternative Text" />
In this example, the forward slash before the closing angle bracket indicates that this is a self-closing tag
Note that HTML tags are enclosed in angle brackets < > and the closing tag has a forward slash / before the tag name. Some tags also require attributes like id, class, src, alt, href, etc., which provide additional information about the tag.
No comments: