Discussion Locked

Protecting or hiding HTML code

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there any way to protect or hide the HTML code behind a document, or any way to prevent the code being displayed by 'view source'?

7 replies

by 4u21der

There is no way to "protect" html source from being viewed. The best bet if you wish to hide code and or styles is to use a scripting language like ( ASP or PHP or CGI ). You can also include files that have links to a Style Sheet.

Hope this helps.

Good Luck!

by ann777

The above answer is correct. There are ways to disable right-clicking or disabling the view function.... but there are "freeware" utilities on the market that will download html code of websites anyway. Don't bother trying.

by kschang

Indeed, there is no way to "hide" the source code for HTML, since HTML is not a programming language. The browser does not translate the HTML in any way, it merely interprets the input and displays the content with the layout/format specified.

As a workaround, there are ways to obfuscate the code, and even semi-encrypt the code by using Javascript. However, it is easily decoded (indeed, it MUST be for the browser to display it!)

One trick you can do is remove all the carriage returns inthe HTML source code. It will be utterly unreadable in "view source" format unless the reader spends time adding them back.

You can find the Javascript "encryption" via search engines easily. You can also use Javascript to disable right-click, go into "kiosk" mode, and such, which would make viewing the source code more difficult, but it's not possible to completely disable the source code viewing.

This discussion is closed to new replies.