HTML Elements

HTML elements are the building blocks of HTML documents. They are used to structure and format the content of a webpage, and to create a hierarchy of information. HTML elements are defined by tags, which are enclosed in angle brackets and placed around the content they describe.

There are many different types of HTML elements, including headings, paragraphs, lists, tables, forms, and images. Each element serves a specific purpose and can be customized with attributes to control its appearance and behavior.

<p>: This element is used to define a paragraph of text.

<p>This is a paragraph of text.</p>
<p>This is another paragraph of text.</p>

<h1>: This element is used to define a heading. There are six levels of headings, ranging from <h1> (the largest) to <h6> (the smallest).

<h1>This is a level 1 heading</h1>
<h2>This is a level 2 heading</h2>
<h3>This is a level 3 heading</h3>

<a>: This element is used to create a hyperlink to another webpage or a specific location on the same webpage. The href attribute is used to specify the destination of the link.

<a href="https://www.example.com">Click here to visit example.com</a>

<img>: This element is used to insert an image into a webpage. The src attribute is used to specify the location of the image file

<img src="/images/river.jpg" alt="A picture of a river">

The <ul> tag stands for "unordered list" and is used to create a list of items that are not numbered. The <ol> tag stands for "ordered list" and is used to create a list of items that are numbered. The list items are denoted by the <li> tag, and they are usually displayed with a bullet point.

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>
<ol>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

Tables are another important HTML element that is used to display data in a tabular format. Tables are defined by the <table> tag, and are made up of rows and columns. Table rows are defined by the <tr> tag, and table cells are defined by the <td> tag. Tables are often used to display data that is organized into rows and columns, such as financial data or product information.

<table>
  <tr>
    <th>Column 1</th>
    <th>Column 2</th>
  </tr>
  <tr>
    <td>Row 1, Cell 1</td>
    <td>Row 1, Cell 2</td>
  </tr>
  <tr>
    <td>Row 2, Cell 1</td>
    <td>Row 2, Cell 2</td>
  </tr>
</table>

Forms are used to collect user input, such as names, addresses, and email addresses. Forms are defined by the <form> tag, and are made up of form elements, such as text fields, buttons, and checkboxes. Forms are an important part of many websites, and are used for a variety of purposes, including registration, login, and data collection.

<div>: This element is used to create a container for other elements.

  <div>
    <p>This paragraph is inside a div element.</p>
    <ul>
      <li>List item 1</li>
      <li>List item 2</li>
    </ul>
  </div>