Skip to main content

Command Palette

Search for a command to run...

HTML Basics - The Web's Skeleton

Published
3 min read
Understanding HTML Tags and Elements

HTML (HyperText Markup Language) is the backbone of web development. It provides the structure and layout for web pages, making it essential for anyone diving into web development to understand HTML tags and elements.

What Are HTML Tags and Elements?

An HTML tag is a piece of code that defines the beginning and end of an HTML element. Tags are enclosed in angle brackets (<>). For example:

<p>

An HTML element, on the other hand, consists of a start tag, its content (if any), and an end tag. Here’s an example of an element:

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

In this example:

  • <p> is the start tag.

  • This is a paragraph. is the content.

  • </p> is the end tag.

Types of HTML Tags

HTML tags can be broadly categorized into:

  1. Paired Tags: These have both opening and closing tags.

    • Example: <h1></h1>, <p></p>
  2. Self-closing Tags: These do not require a closing tag and are written with a slash at the end of the tag.

    • Example: <img />, <br />

Commonly Used HTML Tags

Here are some of the most commonly used HTML tags and their purposes:

  • ``: The root element that represents the entire HTML document.

  • ``: Contains metadata about the document (e.g., <title>, <meta> tags).

  • ``: Sets the title of the web page, displayed on the browser tab.

  • ``: Contains the visible content of the web page.

  • ** to **: Define headings, with <h1> being the largest and <h6> the smallest.

  • ``: Defines a paragraph.

  • ``: Creates hyperlinks.

  • ``: Embeds images.

  • ** and **: Create unordered and ordered lists, respectively.

  • ``: Defines a list item.

  • ``: Defines a division or section of the document.

  • ``: Inline container for text or other elements.

Attributes in HTML Tags

HTML tags can have attributes that provide additional information about the element. Attributes are always specified in the opening tag and follow the format name="value".

Example:

<img src="image.jpg" alt="Description of the image" width="300" height="200">
  • src: Specifies the path to the image.

  • alt: Provides alternative text if the image cannot be displayed.

  • width and height: Set the dimensions of the image.

Nesting of HTML Elements

HTML elements can be nested within one another. Proper nesting is crucial for the correct rendering of web pages.

Example:

<div>
  <h1>Welcome to My Website</h1>
  <p>This is a paragraph inside a div.</p>
</div>

Conclusion

Understanding HTML tags and elements is the first step toward mastering web development. These building blocks form the foundation of every website. By learning how to structure content with proper tags and attributes, you can create well-organized, accessible, and visually appealing web pages.

More from this blog

chaicode

6 posts