Code Conquest

  • Home
  • What is Coding?
  • Tutorials
  • Training
  • Reviews
  • Knowledge Center
  • Versus
  • Blog
You are here: Home / Learn To Code / How to Hide an HTML Code

How to Hide an HTML Code

March 22, 2021 by Code Conquest

Did you know there’s a way to hide an HTML code or text snippet on your site?

Every once in a while, it may be necessary to hide text or content on a website. For example, if you need to remove a segment of text, because a situation has changed, yet you want to keep it just in case you need to restore it later. Instead of deleting the content entirely, it’s possible to hide it behind a unique code.

When hidden, the text remains part of the HTML that you’ve written on the backend of your site, but it’s not visible to the average user. This is also an excellent tool to use when following an HTML tutorial or learning the language. You can play around with the visibility of text and content rather easily.

How Do You Hide an HTML Code?

The process for hiding HTML is pretty easy, and it involves doing something called “commenting out” the content. When you create documents in HTML, you can leave comments to help other developers and designers understand what each snippet is for.

In your coding tool, whether that’s something like notepad, a developer studio, or just a web editor, you’ll want to do the following:

1) Find the paragraph or block of text you wish to hide. Make sure your active cursor is at the front of that block and click to edit.

2) Type this before the first character:

<!---

This tells browsers and applications to hide anything after.

3) Find the last character in the block of text you want to hide, move the cursor there to edit.

4) Type this after the last character:

--->

This tells the browser to stop hiding the content.

5) Save your document, and either upload it to your website’s server or test it in a browser window.

What Is “Comment Code” Used for?

Every developer or coder has a different approach. When you write code you often add a bit of your personality to the project, because there are many ways to achieve a particular function or task. When someone else comes in to clean up or work on your code, they might not understand what you were trying to do or why you did something a particular way. That is precisely what HTML comments are for, and they also exist across every programming language.

So, even though we did this with HTML, you can do the same thing with other languages too. The code to do so is different from language to language, so keep that in mind.

You can comment out certain blocks of text or content to detail what you are doing with the active code. You can also use this to hide certain content, just like we did above.

Give it a try next time you’re writing code!

Related



Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.

Popular Series

  • What is Coding?
  • How to Make Your First Website
  • Understanding Hex Color Codes
  • How to Become a Coder in 6 Months: a Step-by-Step Action Plan
  • How to Start a Coding Project

Get Our Newsletter

Enter your email address and we'll notify you whenever we add something new to the site.

Popular Blog Posts

  • The 50 Best Websites to Learn Python
  • The 50 Best Websites to Learn JavaScript
  • The 50 Best Websites to Learn PHP
  • Want to Switch Careers? Coding May Be the Perfect Solution!
  • 9 of the Hottest Tech Skills Hiring Managers Look for on LinkedIn

Latest Blog Posts

  • Effective Strategies For Debugging Code
  • Effective Time Management Tips for Programmers
  • Code Documentation: Tools and Techniques
  • Is Data Analytics Hard to Learn?
  • Comparing Data Science vs Computer Science

Explore Code Conquest

  • What is Coding?
  • Free Code Tutorials
  • Coding Training Recommendations
  • Coding Training Reviews
  • Knowledge Center
  • Cheat Sheets
  • Coding Quizzes
  • Versus

Deals, Discounts and Coupons

Deals

Code Conquest

  • Home
  • About
  • Privacy Policy
  • Contact Us
  • Terms of Use
  • Write for Us
  • Featured Review

Copyright © 2025 Code Conquest · About · Terms · Privacy · Contact Us · Write For Us