What is an HTML Tag?


An HTML tag is a keyword used to define elements in an HTML document. Tags are usually enclosed in angle brackets like this: <tagname>


Example 1: <p>tag


Code:

<p>This is a paragraph.<p>

Output:

This is a paragraph.

What is an HTML Element?


An HTML element includes the start tag, content, and the end tag.


Example 2: HTML element structure


Code:

<h1>Welcome to My Website<h1>

Output:

Welcome to My Website

Here:

  • <h1> = start tag
  • Welcome to My Website = content
  • <h1> = end tag

Together, it's called an HTML element.


Example 3: <a> tag (anchor tag – used for hyperlinks)


Code:

<a href="https://www.google.com">Visit Google</a>

Output:

Visit Google

Example 4: <img> tag (used to display images)


Code:

<img src="https://via.placeholder.com/100" alt="Placeholder Image">

Example 5: <ul> and <li> tags (unordered list)


Code:

<ul>
  <li>HTML Basics</li>
  <li>CSS Styling</li>
  <li>JavaScript Fundamentals</li>
</ul>

Output:

  • HTML Basics
  • CSS Styling
  • JavaScript Fundamentals

    Example 6: <table> tag (used to create a table)


    Code:

    <table border="1">
      <tr>
        <th>Language</th>
        <th>Use</th>
      </tr>
      <tr>
        <td>HTML</td>
        <td>Structure</td>
      </tr>
      <tr>
        <td>CSS</td>
        <td>Design</td>
      </tr>
    </table>
    

    Output:

    Language    Use
    HTML        Structure
    CSS         Design