Banner image for a switzCodes blog post titled ‘How I Learned to Comment My Code in HTML – Making Code Easy to Read and Maintain,’ featuring the switzCodes logo in dark blue, white, and green with notepad-style visuals.

📄 How I Learned to Comment My Code in HTML - Making Code Easy to Read and Maintain

📅 October 6, 2025

✍️ By Evans

Hey friends! 👋

When I first started writing HTML, my code looked like a wall of tags — no explanations, no reminders, just chaos 😅.

Then I discovered something that completely changed the way I organize my code: HTML comments!

They don’t show up on your webpage, but they help you (and others) understand what’s going on inside your code.

💭 What Is a Comment in HTML?

An HTML comment is text you write only for developers — the browser ignores it.

Here’s what it looks like:


<!-- This is a comment -->
<p>Hello World!</p>
                        

The line inside <!-- --> won’t appear on your webpage.

It’s just a note in your code.

✍️ How I Use Comments

I started using comments to separate different sections of my code.

Example:


<!-- Header Section -->
<header>
  <h1>Welcome to SwitzCodes</h1>
</header>

<!-- Main Content -->
<main>
  <p>This is where the main content goes.</p>
</main>

<!-- Footer -->
<footer>
  <p>© 2025 SwitzCodes</p>
</footer>
                        

Now, when I scroll through my code, I can instantly tell which part does what.

🧠 Why Comments Are Super Helpful

Here’s what I’ve learned about using comments wisely:

  • Stay organized – Labeling sections makes your HTML easier to read.
  • Explain tricky parts – Leave notes for yourself (or others) about why you did something.
  • Debug faster – You can “hide” parts of your code temporarily by commenting them out.

For example:


<!-- <p>This paragraph is hidden for now.</p> -->
                        

That’s a trick I use when testing layouts.

🚫 A Small Warning

Don’t overuse comments — too many can clutter your code.

Just add them where they add clarity.

And remember: comments are visible in your page’s source code, so never put private info in them (like passwords or notes you don’t want others to see).

🎯 What I Learned

Learning to comment my HTML was a small step, but it made a big difference.

Now, when I style my pages, I know exactly where and how to apply changes without breaking my layout.

Now, my code feels cleaner, more readable, and easier to update.

It’s one of those habits that separates a beginner from someone writing smart, maintainable code.

👉 What’s Next?

Up next, I’ll dive into HTML Meta Tags – Controlling How My Page Appears in Search Engines. That’s where I’ll start learning how to make my pages stand out on Google! 🌐

Catch you in the next one, and keep coding! 💻

— Evans 🚀