|Is there a way to encrypt CSS files?|
Is there a way to encrypt the CSS files or should one just encrypt the link that points to it?
Like with anything online - if its on the internet, then its impossible to stop people looking at how it was built.
If you're that paranoid about people stealing your code, then either dont publish it, or make your site a giant image file, or a pdf file..
As much as it urks me when people steal my stuff, I've done it plenty of times myself ;)
Short answer....No, there isn't.
If the browser can use the CSS file then the end user can read/copy it.
I wouldn't be worried about it too much, even if someone takes your CSS they still have a lot of work ahead of them creating html elements that take advantage of the classes.
encrypt would imply the browser can't get to it, I suppose you meant obfuscate.
Class names and IDs might be mangled beyond making sense to us humans, but I'd strongly advice against it, as it'll make your own life more miserable than those of people trying to understand techniques.
It's not worth worrying about, it only because one need only tweak almost any CSS or HTML to make a 'fresh, new' page from almost any existing page on the web. One could probably take a 1,000 pages at random and then 'group' them into a pretty small number of 'design themes'. The specific CSS and/or HTML just isn't that big a deal.
Personally, I like nice clean hand-coding. I could, and sometimes do, take a page that looks great, strip out the junk, clean up the code, swap in new colors, background-images, add in my own 'upgrading' and it's good to go. So long as ppeople aren't taking my text (which we defend vigorously whenever possible - depends on who and where they are located), they can have the code. Our service and reputation can't be stolen, copied, or replicated without a whole lot of actual work.
BTW - When I do 'lift' a design that I really like, it never comes out looking like the original by the time I'm done doing tweaking and customizing. Of course, people that can't read (much less write) code do just copy and paste entire .css and .html files, but how much of a threat can they be? Content and service are King and Queen. We average minutes between order submission and email confirmation that includes tracking number. Once we have you - we own you forever:))
Have your CSS files parsed by PHP; then put in place a triple-layer security system:
Check for your domain name in the HTTP_REFERER data
Check that the user has a cookie as issued by all your true site pages, and as expires in 2 seconds after issue.
If either of the above tests fail; serve up a CSS file which is incorrect, old, broken etc. - make them think they've got the the CSS but haven't been able to install it properly.
... and for people with cookies turned off, or in the event the HTTP_REFERER is blank (as is the case with certain UAs or _any_ UA equipped with certain protect-my-privacy addons) ... then what do you do? Especially since they can still just take the already-served-up CSS and store it on their own server ...
I say -- don't worry about it. Those who really want to steal it will be able to do so anyway. All you can do is make it more or less difficult for them (and yourself).
DrDoc; CSS is not an important part of site functionality (at least it shouldn't be). The worst that will happen is that things look plain and minimalist.
... which in an ecommerce environment is sure to cost you sales; same goes for professional services.
An informational or educational site wouldn't suffer, on the other hand.