473,385 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to modularize stylesheets (and avoid collisions)?

kj

I would like to break down my stylesheets into a modules library,
but I can't figure out how to solve the problem of avoiding namespace
collisions for CSS classnames. What's considered "best practice"
in this area?

TIA!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Dec 7 '06 #1
3 2321
kj wrote:
I would like to break down my stylesheets into a modules library,
but I can't figure out how to solve the problem of avoiding namespace
collisions for CSS classnames. What's considered "best practice"
in this area?
We use a single generalised style sheet to control the display of any
content appearing in our pure content-driven sites. Essentially this
means we have the idea of a virtualised page layout that means we can
customise any content to any style we wish just from CSS (we have
one-click template switching examples on the site). This means our CSS
style sheets are richer and bigger than normal, but the benefit is
complete flexibility. It also means we have standardised names for
items and areas on the page.

Our approach is to consider the page as a series of layers, rather than
as a series of linear text elements (this follows the box model pretty
readily)

For instance the main .pagelayout 'box' has boxs that divide the page
into key areas (header, leftcol, main, rightcol, bottom etc) as layers
'on top' of it. From here we then create sub-classes (eg headright,
headmain, headtop). If necessary we can also subselect elements below
this. To swap from one header style to another is just a case of
overwriting these styles which allows a library of styles to be built
up and used.

If we place what we call 'components' into the HTML (eg a gallery
object, a music player object etc), then these take their own styling
following a similar pattern and naming convention again thinking of
each as a layer on top of the containing box. Once again this means
that components can be styled with a range of different CSS, and by
separating things this way means we can mix and match stylesheets.
Saul
www.notanant.com
communities of websites

Dec 7 '06 #2
Hi KJ,

I'd support Saul's post above in terms of best practice. Generally when
we build stuff we initially just lay all the content out in some really
light structural HTML so we have the pieces we are dealing with and
then start splitting it up using some divs as logical sections, so you
often end up with a header which might contain branding and navigation
then you'll end up with a footer, mainbody etc.

Once we are past that point we'll look at reusable components that may
or may not be called in, maybe things like a promo area or a login to a
system etc. If you are using a CMS [and even if you aren't and are just
straight building with HTML] then then you can decide when you might
want to "split out" to use other CSS files as well.

To a certain extent it all comes down to style. There are those that
say your definitions should be on one line, some others prefer listed
downwards. I'm a big fan of having a base style sheet that contains 80%
of the site and the 20% that may need to be a bit more detailed is
dropped out to another file which is called in when you need it. I'm an
old school C++ programmer though and it makes your life a *lot* easier
to have one object in one file but this isn't necessary for everything.

I'd be interested to see how many different "general" ways of putting
things together there are?

We also always use CSS Signatures so that people can override our
stylesheets if they really want to... a couple of the designers I work
with have created some pretty cool mashups doing this as well...

Cheers
AndrewF

Dec 7 '06 #3
In article <11********************@16g2000cwy.googlegroups.co m>,
"AndrewF" <an****@transitionkiteboarding.comwrote:
Hi KJ,

I'd support Saul's post above in terms of best practice.
Hi AndrewF,

Where is this "above"? Please quote some of the things you are
replying to.

--
dorayme
Dec 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: comp.lang.php | last post by:
I've heard numerous and varied commentaries here and on other fora regarding PHP and the concept of threads. Coming from a Java background I understand how threads benefit to prevent collisions,...
4
by: Howie | last post by:
Hi, we have an ActiveX Application with a 3D scene management. During calculations in a function (foo1) wich is startet every mousemove or mouseclick or by user who is click a button on a...
14
by: Jacqui or (maybe) Pete | last post by:
Having just answered a question about multiple linked stylesheets, I thought I'd have a look at browser support. There's a quick test page here: http://www.porjes.com/ms/ I wrote it...
72
by: Herbert | last post by:
I'm still relativey new to stylesheets, so I'm hoping that the way I'm going about things can be seriously improved upon, i.e . I just haven't undersood something obvious about the 'cascading'...
31
by: wallster | last post by:
please keep the flaming to a minimum (a bucket of water is next to me) but I have a question someone here might be able to explain in basic terms for a dunce like me. I helped a friend put...
6
by: Nels Olsen | last post by:
Our company is rewriting our product in .NET. The old product is in PowerBuilder, which is heavy on Hungarian notation. We are approaching the time where we have to finalize naming conventions for...
14
by: ToddLMorgan | last post by:
Summary: How should multiple (related) projects be arranged (structured) and configured so that the following is possible: o Sharing common code (one of the projects would be a "common" project...
4
by: RgeeK | last post by:
From my newbie perspective I understand that Javascript is a single threaded environment and so interrupt-driven events are going to be somewhat challenging. But, I have an issue which seems to...
1
by: Jinky123 | last post by:
Hi all, Here's a question to be sure: how do I modularize CSS menus? In other words, I want to define a menu (e.g., OrangeTree Horizontal Menu) once, and then call/invoke it from any number...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.