Forum Moderators: not2easy
The W3.org CSS specs are available to all. Anyone with even a moderate working knowledge of CSS can emulate any given style or stylesheet.
I strongly suspect that your 'belief' that CSS is some sort of crytic formula to be 'protected' stems from the use of an EDITOR to create your styles, istead of originating from a honest knowledge of the CSS Specifications.
Here is the best advice I can offer: STOP USING AN EDITOR TO CREATE YOUR STYLES.
You will only, truly begin to comprehend the mechanisms and style-relationships of CSS, once you begin to write your styles by hand.
I honestly cannot even offer the excuse of 'editors-as-time-savers.' Especially not, if you actually care about your code...
- papabaer
Wanna protect your 'styles'?
Write really bad code!
Reality check: there is nothing to "protect."
Why would you protect your CSS?
I'd like to avoid my competition looking at my style sheet and figuring out how I shaved
5k to 10k of my page size.
- positioning within table cells
- drop shadow on tables
- assigning body tag attributes
etc...
are all things you can do with CSS that would reduce the code bloat of your document
as well help you avoid using images for design purposes.
With a SEO perspective; code to content ratio and page size are issues that must be addressed.
Maybe at the present time we cannot prevent; however we can alteast make it difficult for
newcomers to copy paste your CSS.
I've analyzed the top sites in my industry; and they are not using CSS to it's full potential,
I would even go as far as saying that they're using 20% of the power of CSS. They would reduce
their code and page size substantially if they began using CSS.
Note that the philosophy behind CSS is simplicity, and any techniques to hide it subvert that.
Why Bother
I am not surprised that you got more responses to the effect of 'Why would you want to?' compared to 'This is how:'. WebmasterWorld is all about people sharing knowledge and educating each other in an open way, and that is the sort of person who hangs out here, so the responses posted are no surprise. However, I don't agree with some of these responses. An argument like "...The W3.org CSS specs are available to all. Anyone with even a moderate working knowledge of CSS can emulate any given style or stylesheet..." is kind of like arguing that the C++ specs are available for anyone to download, so why bother protecting IPR of a piece of software, any team of software developers can write a program which acts, looks and feels like yours, given enough time. Sure, css is a pretty simple 'language' and can be learnt relatively quickly, but there are many (most?) out there whose skills are still rudimentary (me included), and even advanced proponents can spend considerable amounts of time getting their css designs right. If it took time and effort to create, you have every right to protect it.
What is there to protect? A whole range of things, from the graphic design of the layout to the technical implimentation . Not that obscuring your css will prevent theft, but it can be a deterant.
Not that I'd bother or recommend obscuring css; just thought I'd balance out the views a bit.
Shawn
In mozilla, you can use data: URIs (RFC 2397) to obfuscate things by inlining your external style sheets (you can use these for any URI in mozilla). With the appropriate levels of indirection you can really ofuscate things, but then, once you know what's going on, its easy to extract them (and just as easy to view them in Mozilla with the DOM Inspector).
(I really don't blabber about the DOM Inspector enough, it really is the best damn tool for playing with CSS you'll ever find.)
Load the code into: [dynamicdrive.com...]
for an example of what the technique can do.
To be honest though, if your competitors don't have enough brain cells to figure out the benefits of CSS for themselves, then I wouldn't consider them much competition!
asp