TGViewer
Web Development Web Development @webdevcoursefree ยท 79.6K subscribers
Post #4066 979
๐ŸŒ Web Development Roadmap โ€” Part 13

HTML Syntax, Tags & Elements

Now that you understand what HTML is, let's learn how HTML actually works.

1. What is an HTML Tag?

A tag tells the browser what type of content something is.

Example:

<h1>Hello World</h1>


Here:

<h1> โ†’ opening tag

Hello World โ†’ content

</h1> โ†’ closing tag

The complete structure is called an HTML element.

2. HTML Element

An HTML element usually looks like this:

<tag>Content</tag>


For example:

<p>This is a paragraph.</p>
<h2>About Me</h2>
<button>Click Me</button>


Think of an element as a complete building block of a webpage.

3. Opening and Closing Tags

Most HTML elements have both.

<p>Hello</p>


Opening:

<p>

Closing:

</p>

Notice the / in the closing tag.

4. Some Tags Don't Need a Closing Tag

Some HTML elements are void elements.

Example:

<img src="photo.jpg" alt="My photo">
<br>
<hr>


They don't have a separate closing tag.

5. HTML Attributes

Attributes provide additional information about an element.

Example:

<a href="https://example.com">Visit Website</a>


Here:

href="https://example.com" is an attribute.

Another example:

<img src="profile.jpg" alt="Profile photo">


The image has two attributes:

src โ†’ location of the image

alt โ†’ description of the image

6. Attributes Usually Go Inside the Opening Tag

Correct:

<p class="description">Hello</p>


Incorrect:

<p>Hello</p class="description">


7. Nesting Elements

HTML elements can be placed inside other elements.

Example:

<div>
<h1>My Website</h1>
<p>Welcome to my website.</p>
</div>


Here:

<div>
โ”œโ”€โ”€ <h1>
โ””โ”€โ”€ <p>


The <h1> and <p> elements are inside the <div>.

8. Proper Nesting Matters

Correct:

<p>
Hello <strong>World</strong>
</p>


Incorrect:

<p>
Hello <strong>World</p></strong>


HTML elements should be properly nested.

9. HTML Comments

Comments allow developers to leave notes in their code.

<!-- This is a comment -->


The browser doesn't display the comment as webpage content.

Example:

<!-- Website heading -->
<h1>My Portfolio</h1>


10. A Simple HTML Example

<!DOCTYPE html>
<html>
<head>
<title>My Portfolio</title>
</head>
<body>

<h1>Welcome to My Portfolio</h1>
<p>I am learning web development.</p>
<a href="about.html">About Me</a>

</body>
</html>
  • โค 4
More from @webdevcoursefree
  1. Oct 5, 2026The browser reads the HTML structure and builds the webpage from these elements. Key Takeaโ€ฆ
  2. Sep 29, 2026It can contain things such as: โ€ข Page title โ€ข Metadata โ€ข Links to CSS โ€ข Other informationโ€ฆ
  3. Sep 29, 2026๐ŸŒ Web Development Roadmap โ€” Part 12 ๐Ÿ—๏ธ HTML โ€” What Is HTML and Why Do We Need It? HTML iโ€ฆ
  4. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
  5. Sep 28, 2026Post #4062
  6. Sep 28, 2026Post #4061
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’