File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes CSS Naming Conventions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "CSS Naming Conventions" Watch "CSS Naming Conventions" New topic

CSS Naming Conventions

William Keydel

Joined: Aug 31, 2006
Posts: 1
Does your book provide any suggestions on naming conventions and organization of the .css document(s)? I find that I struggle to remember the class names and to create good names because I haven't come across suggestions for good naming conventions.
Mike Bowers
Ranch Hand

Joined: Oct 08, 2007
Posts: 42
Does your book provide any suggestions on naming conventions and organization of the .css document(s)?

Yes it does. Chapters 1 and 2 of Pro CSS and HTML Design Patterns have several sections that address this topic.

You can see examples of these items at the book's website

Chapter 1 discusses the pros and cons of using separate .css files. On the positive side, multiple external .css files make it very easy to modify an entire web site, parts of a web site, or even a single page of a web site. On the other hand, each .css file you add to a web page delays the downloading of the page by 0.1 to 0.5 seconds per file � even if the file has been cached by the browser (a browser still has to ask the server if a cached file has been modified and needs to be downloaded again).

Chapter 2 shows how to reference external .css files and suggests naming conventions and a strategy for loading multiple .css file for different purposes. Chapter 2 also shows how to conditionally load external .css files. This is particularly useful for Internet Explorer 6 and 7, which sometimes requires different CSS settings to work properly. Examples from my book are at the following two links: and

By the way, if you are a developer, you'll love this book because it is all about the best practices for coding XHTML and CSS. I wrote this book because I'm a developer and couldn't find any good CSS books for developers � they were all for designers. I have included a wealth of information on coding XHTML and CSS. The book also has a wealth of information on design patterns that you can quickly use in your code to create cross-browser compliant solutions.
I agree. Here's the link:
subject: CSS Naming Conventions
It's not a secret anymore!