00 Votes

HTML: How to hide something in the source code?

Question by Guest | 2014-01-08 at 17:08

In my source code for my website, I have written some comments making it clear to me to maintain and understand the source.

The problem is that now anyone can view these comments in his browser, simply by looking at the source code of my website. Since partially sensitive information are included in the comments, I would like to prevent this.

Is there any way to hide the comments in the source code so that they can no longer be read?

ReplyPositiveNegative
0Best Answer0 Votes

If you are working with pure HTML, it is advisable to remove your comments before publishing. A folder with the pages with comments remain on your computer, you make a copy of this folder, you remove the comments and you only upload these adjusted files to your server.

The removing of the comments can be made manually or using a suitable program such as our TextConverter.

Of course, it is easier if you are using PHP files for your website. Any comment within a PHP code section will not appear in public in the HTML code.

Here is a small example of this:

<!-- This HTML comment is visible-->
 
<p>Text 1</p>
 
<?php
  // This PHP comment remains invisible
  echo '<p>Text 2</p>';
?>

Like "Text 1", the first comment is interpreted as plain text and it is visible in the source code. Apart from this, everything inside of <?php ... ?> is interpreted as PHP code and comments within these sections are invisible to the source code.

Thus, it makes sense to always put comments exclusively within PHP code sections as far as this is not impracticable. 
2014-01-08 at 17:18

ReplyPositive Negative
Reply

Related Topics

jQuery: Show and hide elements

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.