Protecting HTML/CSS fro being copied temporally?

Hi there,

I’m wondering if there is a way to stop people from copying code from a website. I know this may be a bit of a basic question, but can you really stop people from viewing the source code of a website? I’m thinking of a really hacky way of inserting it through an iframe, but I guess this will still be accessible through the source.

Any suggestions on whether this is possible would be great.

Thanks

I would suggest that you do not let paranoia effect your thought processes. :unhappy:

Concern yourself with plagiarism of your actual content, if necessary, but
definitely not about the HTML and CSS. :winky:

coothead

3 Likes

What does that mean? Your title says HTML/CSS and if that is what you are asking about then no, it cannot be protected. If you are thinking of something else in your mind then note that you do not say it for us.

Source code usually means HTML/CSS/JS.

HTML and CSS is “client-side” code, that is code that is sent from the server to the client.
If it’s sent to the client, the client can see it, copy it, do as they please. The only way to prevent this is to not send any code to the client, in which case they may see a blank screen, or in other words, not having a public website.

5 Likes

Hello @toolman,
I would recommend disabling the right click action. This disables the user to right click, therefore disabling them to access the inspect element. I would do a quick google search to see snippets of possible solutions. There is another solution, one I don’t have much knowledge of, but it basically hashes your code so it’s unreadable and renders useless if copied.

This really is not a good idea. For one thing it is the easiest thing to disable, and for another it annoys a lot of visitors - and visitors are the last people you want to annoy.

There really is no good reason to stop people from viewing your source code in any event.

3 Likes

I agree. Most visitors aren’t going to try to find your source code.

I have been programming for nearly half a century and the term source code has existed since before my time. HTML has existed for less than 30 years.

Source code can absolutely refer to server-side code such as PHP. It seems strange to me to refer to HTML and CSS as source code; source code has logic. HTML and CSS are basically UI things; they are more of a word-processing format.

Yes, many people also think CSS is a language, but it’s truly just script.

It does not disable the developer tool. And even if you disable that, it is possible to use HTTP (such as what CURL does) to get the HTML file and the others. So you might be able to make it difficult for the non-technical people from accessing the code but those of us that are more technically inclined can get around anything that someone thinks would work.

You will impress us if you can find that but you cannot.

@SamuelCalifornia,
It’s called JavaScript Obfuscator, and just like the name suggests it Obfuscates your code making it unreadable to anyone trying to copy it. But it only protects javascript code. This is their website.

Thanks for the replies. I am trying to stop the HTML/CSS from being copied.

I might do something similar to this:

But without the remove frame link.

Is there a way I can insert an iframe using JavaScript and then use the obfuscator?

Everyone is distracting the important issue here. The most common way to protect website source code (not HTML and CSS) is to do it server-side. Source code such as PHP and C# are totally protected unless someone screws up. JavaScript can also be used server-side but I am unfamiliar with the details.

The title of the topic specifically mentions HTML/CSS. Anything else is off-topic.

Probably, but it seems a lot of overcomplication for something that could easlily be undone if someone wanted to.

2 Likes

I’m able to look at the view-source of both the page and the iframe. What is the “something” to be seen there?

1 Like

Obfuscation: How to hide code only from those who don’t understand code anyway. :lol:

3 Likes

Yes. Take a picture of your website, upload that, and people won’t be able to copy the code of it.

In all seriousness, no. The browser has to be able to read all the output code in order to render your webpage, which means the browser must have the output code, which means anyone can access the output code.

The idea of putting out a public website is that it is publicly available.

2 Likes

Then you should have said that when Liamgrossman mentioned it.

No, you can’t stop someone from copying the HTML/CSS you send to the browser. One alternative is to make your pages as PDF pages, then they can’t copy HTML/CSS. This is not a good way to go about it, however.