Hide view source?

*{Hi guys,
I know this is going to sound selfish, but I was wobdering— is there any way one can prevent the source of their website from being viewed?

I know the one problem with this is that each browser has their own method for users to view a pages source, but since browsers read css and display the site as per the css styling guidlines— is it possible or someway one could do like a


I mean, I am pretty sure there aren’t any attributes that could do that, but if anyone has any thoughts or solutions— regardless of language— I would like to see what you guys think.

Team 1504

There isn’t anyway to block it. If there was, I could always save the page to my site and view it.

Also I am assuming this thread came from http://www.sitepoint.com/forums/html-xhtml-52/include-html-separate-file-739585.html


just add the following attribute (in red) to your HTML tag –

<html [COLOR="Red"]viewsource="no"[/COLOR]>

also, pretend i wrote this reply tomorrow :wink:

Don’t bother trying, this question gets asked on a regular basis. You’d be wasting your time ‘trying’ other than possibly outwitting or slowing complete newbie amateurs stealing your HTML/CSS source code.

Also read http://www.sitepoint.com/forums/net-141/how-block-view-source-419751.html Team1504

also, pretend i wrote this reply tomorrow

lol, assumed!

@ O.P, their is no way (known way) by which you can hide your source code from being viewed in different browsers (or at least in a single browser)

If there would have been any such attribute or piece of code then there wouldn’t be clones of websites like facebook, twitter and all those Giants …

awesome… i actually came up with (almost) the exact same answer as five years ago!!!


I know, I laughed hard at that. :cool:

Yup, almost the same :rofl:

5 years back, you have recommended to add viewsource=“no” in the body tag and now you are recommending to use it in the html tag :eye:

hope people will get a lesson from this (and the other one) & will stop asking ‘How to hide Source code’ kinda questions in future!


Wow this thread blew up, which I assumed it would being a controvestial topic, but much faster than it did.

First, I apologise for posting it as it seems it has been posted before. Secondly, I apologise for all the spelling mistakes as it was early in the morning for me.

So I have a few questions and answers that are in the order of the posts:
1.) What does saving and viewing a page mean? I can see how one can do that with viewsource, but I do not understand how blocking viewsource has anything to do with allowing one to save and view; in fact, it does the opposite.

If there was, I could always save the page to my site and view it.

2.) I can see how this would seem related to my html include thread but not they are not related. In my years of web design, I have always wondered if preventing view source was possible.

3.) r937, why should I pretend you wrote this tomorrow? Are you not supposed to be on sp forums?


You’d be wasting your time ‘trying’ other than possibly outwitting or slowing complete newbie amateurs stealing your HTML/CSS source code.

I though so. Its just that I have been working really hard on one of my projects for a client and I know it sounds pompous, but I would hate for someone to just steal my design or code.
Because, said client, has told me that visitors of his site had asked if they could use it the layout and code or some that just stole it and he found it on the web. Thus, he created a flash site :nono: to prevent view source and now he wants an actual modern and innovative site and hired me.

5.) haha I lol’d too when I saw that viewsource=“no” because I thought that there is no way that it is proper or real syntax. :D:rofl::smiley:

Thank you for all your help though, do you guys have any other recommendations?

Or if you have any more question or comments, feel free to post.

because tomorrow, April 1st, is my special holiday – they named it after guys like me


develop your code with microsoft frontpage or (shudder) microsoft word

then nobody’ll want to steal it


You asked to hide view source. Well saving the page will have to expose the code when they open it their editor of choice. In other words, you can’t stop somebody.

Ahh okay.

Well, that sucks.

Thank you your guys’ help anyway though.

Even if you use one of those $250 “protection” programs that “encrypts” your page source, your visitors will only need about two lines of JavaScript and a web browser to recover the decrypted version of the page.

The only effective way to prevent someone viewing your page source is to not put the page on the web.

Hi team. :slight_smile:

Is there something you didn’t understand the first time you’ve asked this question?

Even this applies from five years ago: :lol:

sovan, please don’t double-post

this thread is being merged with your other one

And I am obviously not gonna do that, because that is what I developed the website for-- to put in on the web.
And thank you for explaining that the purchasable encryption is not wroth it or necessary because my client was looking into that and I will show them this thread as evidence not to buy it.

I, honestly, do not like when client do their own research and tell me to do things. Recommendations are fine and acceptable because they hired me. But i feel that when one looks things up on their own, it defeats the purpose of hiring me. As your designer, my job is to create the best that I can.

Wow, there is some serious Déjà vu going on here.
I honestly do not remember posting that thread.:eek: However, I do remember always wondering about if hiding source was possible.

I guess, that is a problem I have been noticing. Sometime I post a thread and it does not appear in My Sitepoint as being replied too, but out of my own curiosity of going through my old threads or someone PMing me, I am told that someone did reply and wanted to hear back.
Any suggestions on how I can make sure I am subscribed or how to make sure I still get updated?

Thank you for all your helps guys,
+Team 1504.

P.S. If you want to or if it is protocol to combine the threads because of the similarity, then please do so. And I seriously and sincerely apologise, but I do not remember posting that.

Just so everyone can see how easily any attempt to block people viewing their web page source - here are three ways to bypass whatever the web page owner has done using just a couple of lines of JavaScript or just by using the right browser.

View Source Bookmarklet provides a simple view source bookmarklet that you can add to your bookmarks or favourites menu. Whenever a web page tries to block you from the source you use this link to view the source instead of the blocked ones. It will decrypt code produced by almost all of the HTML encryption programs - only setting window.open to null or including an empty iframe at the bottom of the page will defeat it (at least those are the only two techniques I’ve seen $250 encryption software use that prevented this method from working - which I found out by viewing their decrypted source)…

View Source User Script provides the same thing as a userscript but as a link in every frame in every web page. It can be installed directly into Opera, Firefox with Greasemonkey or (with very minor modifications) into Internet Explorer with IE7pro. It will display the source of ANY web page no matter what has been done to encrypt or hide it. The only web pages it can’t decrypt when installed like this are ones the browser can’t decrypt and therefore can’t display.

Another alternative if you can lay your hands on a copy of the original Netscape 7.0 browser. The File/Save option in the menu of that browser saved the decrypted version of scripts immediately after the encrypted version.

When you look at the forum index, any threads that you have contributed to are shown with a black spot on the envelope icon.