HTML Elements

An HTML element is defined by a start tag, an end tag, and the content in between. Most HTML elements can be nested.

What is an HTML Element?

An HTML element is the building block of an HTML document. It is represented by tags. For example, the following is a paragraph element:

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

Key characteristics of an HTML element:

Common HTML Elements

Here are some of the most fundamental and frequently used HTML elements:

Block-level vs. Inline Elements

HTML elements are typically classified as either block-level or inline.

Structure of an HTML Element

Most HTML elements have the following structure:

<tagname attribute="value">Content goes here</tagname>

Example: The Anchor (Link) Element

The <a> element is used to create hyperlinks. It requires the href attribute to specify the URL of the page the link points to.

Link Example

This is a link to the HTML Introduction page.

<a href="/msdn/documentation/html/introduction.html">HTML Introduction</a>

Example: The Image Element

The <img> element is used to embed images. It requires the src attribute for the image source and the alt attribute for alternative text.

Image Example (Placeholder)

Placeholder Image
<img src="image.jpg" alt="Description of image" />

Common HTML Element Categories

Category Description Examples
Document Structure Elements that define the overall structure of the HTML document. <html>, <head>, <body>, <title>
Metadata Elements that provide metadata about the HTML document. <meta>, <link>, <style>
Sectioning Content Elements that define sections of a document, like headings and navigation. <article>, <aside>, <nav>, <section>, <header>, <footer>
Heading Content Elements that define headings for sections. <h1>, <h2>, <h3>, <h4>, <h5>, <h6>
Phrasing Content Elements that define text and inline elements. <p>, <a>, <span>, <strong>, <em>, <code>, <img>
Embedded Content Elements that embed other content into the document. <img>, <audio>, <video>, <iframe>
Form Elements Elements used to create interactive forms. <form>, <input>, <textarea>, <button>, <select>, <label>

Nesting Elements

Elements can be nested inside other elements. This is crucial for creating complex structures. For example, a <ul> (unordered list) element can contain multiple <li> (list item) elements.

<ul>
  <li>First item</li>
  <li>Second item</li>
</ul>

Conclusion

Understanding HTML elements is fundamental to web development. Each element has a specific purpose and structure, and they work together to form the content and layout of web pages.