ASWCode Tutorials

Learn Web Development - From Basics to Advanced

Understanding HTML Tags

In HTML, tags are used to mark or define different parts of a webpage. Tags tell the browser what each part of the page means - for example, a heading, paragraph, image, or link.

1. What Are HTML Tags?

HTML tags are always written inside <> (angle brackets). Most tags come in pairs - an opening tag and a closing tag.

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

Here, <p> starts the paragraph and </p> ends it.

2. Headings: <h1> to <h6>

Headings are used to give titles and organize content. There are 6 heading levels - <h1> is the largest, and <h6> is the smallest.

<h1>This is Heading 1</h1>
<h2>This is Heading 2</h2>
<h3>This is Heading 3</h3>
<h4>This is Heading 4</h4>
<h5>This is Heading 5</h5>
<h6>This is Heading 6</h6>
      

When you open this in a browser, each heading gets smaller. Use:

3. Paragraphs: <p>

The <p> tag defines a block of text. It’s used for normal reading text like explanations, introductions, and articles.

<p>HTML is used to create webpages and structure content.</p>
      

4. Links: <a>

The <a> tag creates a link to another page or website. Use the href attribute to specify the link.

<a href="https://aswcode.com">Visit ASWCode</a>
      

This creates a clickable link to ASWCode. You can open links in a new tab using target="_blank":

<a href="https://aswcode.com" target="_blank">Open in New Tab</a>
    

5. Images: <img>

The <img> tag displays an image. It’s self-closing and requires important attributes:

<img src="/images/html-logo.png" alt="HTML Logo" width="150" />
      

6. Div: <div>

The <div> tag is a container to group elements. It has no visual effect by itself but is useful with CSS for layout.

<div>
  <h2>About ASWCode</h2>
  <p>ASWCode provides free web development tutorials and code snippets.</p>
</div>
      

Next Lesson → HTML Attributes

Previous Lesson → HTML Basics for Beginners

← Back