HTML HTML Tutorial HTML Forms HTML Graphics HTML Media HTML APIs HTML Tags



HTML Elements

HTML (Hypertext Markup Language) is the standard markup language used to create web pages. HTML elements are the building blocks of HTML pages. An HTML element is defined by a start tag, some content, and an end tag. The HTML element is everything from the start tag to the end tag.

HTML elements can be nested (elements can contain other elements). HTML documents consist of a hierarchy of nested HTML elements.

HTML elements can have attributes, which provide additional information about the element. Attributes are always specified in the start tag. Attributes usually come in name/value pairs like: name="value".

Here are some examples of HTML elements:

Heading Elements

HTML has six different heading elements, from h1 to h6. The h1 element is used for the main heading of the page, and the h2 to h6 elements are used for subheadings and other headings on the page. Here is an example of how to use the h1 element:

<h1>This is the main heading</h1>

Paragraph Elements

The p element is used to define a paragraph of text. Here is an example of how to use the p element:

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

Link Elements

The a element is used to create links to other web pages or to other parts of the same page. Here is an example of how to use the a element:

<a href="http://www.example.com">This is a link</a>

Image Elements

The img element is used to display images on a web page. Here is an example of how to use the img element:

<img src="image.jpg" alt="This is an image">

List Elements

HTML has two types of lists: ordered lists and unordered lists. Ordered lists are numbered, and unordered lists are bulleted. Here is an example of how to use the ul and li elements to create an unordered list:

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

Table Elements

The table element is used to create tables on a web page. Here is an example of how to use the table, tr, td, and th elements to create a table:

<table>
  <tr>
    <th>Header 1</th>
    <th>Header 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 Elements

The form element is used to create forms on a web page. Forms are used to collect data from users. Here is an example of how to use the form, input, and button elements to create a form:

<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  <button type="submit">Submit</button>
</form>

These are just a few examples of the many HTML elements that are available. By using these elements, you can create rich and interactive web pages that are easy to navigate and use.

References

Activity