Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Web Design Lobby Forum for general web design issues not specific to scripting or graphics.

Ezilon Directory   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 05-21-2007, 08:09 AM   #1 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
CSS -- Organizing Style Sheets

is your style sheet out of control!!!

I'd love to hear your opinion on the best way to organize CSS (cascading style sheets)
files across a site ::::::

The issue has arisen because my main stylesheet just keeps
getting longer and loooooooonger... and I want to break it up a bit.
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-21-2007, 01:58 PM   #2 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,968
iTrader: 0 / 0%
Latest Blog:
Ok, so we're back

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
The simplest solution is to group your classes:

div.Container, table.cTable td.cCell, p.pParagraph {
...
values here
...
}

and so on...

I use this technique as follows:

the global declarations includes: *, html, body, form, links, headings, div.PageContainer

then, depending on the page structure, I might have:
- a header
- a content
- a footer
Then I'll group all elements which belong to the page structures described above.
This way, I have a compact css file, and I don't have to search it to find something, like a class or something.
If the class is in the header zone, then all I have to do is go to the css file and look in the header zone to find that class.
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-21-2007, 07:39 PM   #3 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Within my css file, I add comments as section headers. Usually...

Quote:
/* General */
Global tags: html, body, link styles, etc.

/* Structure */
div ids to determine page structure

/* [Section] Styles */
Like "Header Styles", "Content Styles", which are section-specific styles, such as li #header, or p footer, etc. Depending on the site, I have 3 or more of these sections.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-22-2007, 10:43 AM   #4 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
Part of the problem here is:
as pages get added to the site i find myself adding more styles to the main
stylesheet

so, the approach that I have been trying to implement is
:
I have 1 main stylesheet (style.css) which contains all
sitewide styles--like common text styles, html redefined
and basic layout.
Deeper in the site you get to pages which are different in design
and utilize a different layout, different elements etc. For those layouts
I have specific stylesheets that are only accessed by those pages and which
are imported after style.css(and possibly overwrite some of it's rules)
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-22-2007, 02:26 PM   #5 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
You can have multiple stylesheets, as needed.

ie. from my university's site:
Code:
<link rel="stylesheet" href="http://communications.uwo.ca/standard1c.css" type="text/css" media="all" /> <link rel="stylesheet" href="http://communications.uwo.ca/standard2c.css" type="text/css" media="all" /> <link rel="stylesheet" href="http://communications.uwo.ca/style3c.css" type="text/css" /> <link rel="stylesheet" href="http://communications.uwo.ca/print.css" type="text/css" media="print" />
I think the hierarchy is such that the first stylesheet overrides the second, and so on.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-01-2007, 01:44 PM   #6 (permalink)
Inactive
 
Join Date: 05-24-07
Location: Everett, WA
Posts: 70
iTrader: 0 / 0%
Latest Blog:
None

Karen_Harwood is on the right pathKaren_Harwood is on the right path
I like to create one main style sheet for the layout styles then create separate sheets for fonts, navigation and other stuff. I included these separate style sheets in the beginning of the layout.css with code like this:

@import url(font.css);
@import url(side-nav.css);
@import url(opt-nav.css);
@import url(top-nav.css);
@import url(pullquote.css);

And to help keep things organized I also comment sections of my css files like this:

/* General styles */

body {
background-image: url(../image/backg.gif);
margin: 0; padding: 0;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
}

When a stylesheet gets to long these commented areas could be broken off into new stylesheets too.

One more thing you can do is to combine styles instead of listing them separating only to repeat common aspects. For example your headers might share a common theme so these can be combined together followed by separate styles for the things that are different:

h1, h2, h3 {
font-weight: bold;
color: #000000;
}
h1 {
font-size: 150%;
}
h2 {
font-size: 130%;
}
h3 {
font-size: 110%;
}

Hope this wasn't too much and I hope it helps!
Karen_Harwood is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-02-2007, 07:14 AM   #7 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Question

This is good but does anyone know for sure about the precedence of rules loaded from style sheets before vs after both from html <link> and CSS @import, and also <link> vs @import??


Also I like to make some comments stand out a bit more...

/* ***** Header ***** */
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-02-2007, 01:04 PM   #8 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
the cascade

Basically it goes like this:

CSS precedence is determined first by specificity
of selector. So, for:

HTML Code:
<p class="blueParagraph" id="orangeParagraph">This is my test paragraph</p>
HTML Code:
p {color:red;} /* is overridden by... */ p.blueParagraph {color:blue;} /* which is in turn overridden by... */ p#orangeParagraph {color:orange;}
regardless of cascading order because p#orangeParagraph is the
most specific selector.

Also note that an inline style will override all other declarations.


then by importance

HTML Code:
p {color:red;}
is overridden by
HTML Code:
p {color:blue !important;}

then by the cascading order

The rules that come earlier in the stylesheet are overridden by equally weighted rules that come later.
The same goes for linked and imported stylesheets, so in this example:

HTML Code:
<style type="text/css"> @import url(test-01.css); @import url(test-02.css); @import url(test-03.css); </style>
for conflicting styles that appear in all 3 stylesheets, the rule in test-03.css will
win out.
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-02-2007, 01:06 PM   #9 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
@import vs. link

On @import vs link:

The link method is used in the head of an HTML document, it does essentially the same thing as @import, so:

HTML Code:
<link rel="stylesheet" type="text/css" href="test-01.css" />
will do the same thing as the @import example above.

However, there are reasons to use one over the other:

css files can not contain any markup, so @import is the only way for a stylesheet to access styles from another style sheet.

If you want to offer alternate stylesheets you must do this with the HTML link tag:

HTML Code:
<link rel="stylesheet" type="text/css" media="screen" href="test-01.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="Charlie's second stylesheet" href="test-02.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="Charlie's third stylesheet" href="test-03.css" />
Finally, using different versions of the @import rule is a way to hide certain stylesheets from certain browsers as not all forms of @import are supported by all browsers.

see http://centricle.com/ref/css/filters/ for info on which browsers support which forms of the @import directive
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-12-2007, 06:18 AM   #10 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
i just read an interesting article called frameworks for designers by Jeff Croft. he talks about abstracting common css tasks to a self-defined css framework layer. Some interesting points, and i like the way recommends organizing stylesheets.
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Organizing Your Thoughts jdspc Forum Lobby 0 12-16-2007 04:08 PM
Website Goals, need help organizing my mind NermalProductions Web Design Lobby 1 07-09-2007 12:59 AM
CSS and SEO - is hiding text with style sheets dangerous?? c-low SEO Forum 6 09-29-2006 12:54 PM
Organizing high-content sites spacefem Web Usability 4 05-01-2004 12:04 PM
Style Sheets raciviusdawn Coding Forum 9 01-14-2004 05:07 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 06:52 PM.
© Copyright 2008 V7 Inc