Welcome to WebmasterWorld Guest from 54.144.124.152

Forum Moderators: not2easy

Message Too Old, No Replies

Content Structure in the CSS document

     

corny

3:40 pm on Nov 4, 2002 (gmt 0)



Are there any recommended structures for CSS documents themselves?

In my own CSS documents, I begin with body, but then do the classes/ids that involve page-layout, then move into font formatting and finish with link formatting.

It ends up something like this:

body{
}
#leftside{
}
#middle{
}
#rightside{
}

p h1 li etc{
}

#contextual fontstuff{
}

a{
}
#contextual a{
}

and so on.

I suppose some have the contextual elements adjacent to the parents instead of categorizing by what the id/class does.

How do you structure your CSS?

edit_g

3:55 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've found that keeping the font stuff and the layout stuff in two different stylesheets is easier. Then just link to both of them. This is just down to personal preference though (and working on big sites, where keeping it all in one is not sensible at all).

Nick_W

4:07 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I generally mirror the html flow. That way when I see something awry on my page, I know roughly where to find it.

As for general classes etc: At the bottom mainly ;)

Nick

pageoneresults

4:12 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I've been keeping mine in alphabetical order. Makes it easier to manage. I've done some research on this and cannot find anything that says the rules should be in a certain order.

andreasfriedrich

4:39 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I try to keep them in a completely random order, so that when I need to change a certain class the probability that I am already at the right point within the file is the same for all definitions contained within the file and all points within the file. ;)

The algo to maintain such a random order is pretty easy. Just put a new definition whereever you already are in that file.

I rely on good comments within my css files to find the ones I need. The comments are then stripped of by my cms on publishing the site.

Andreas

madcat

10:42 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you structure your CSS?

Like edit_g I split it up. I'll have one sheet dedicated to the actual layout/positioning. One sheet for the element styles and usaully one for navigation. If there are separate dirs I might have a .css folder dedicated to that directory alone.

Within the .css files I tend to start with the body tag and work my way down through id's and <div>'s. Then more general rules and classes round out the bottom. But it's all subjective- no set way at all. Comment your .css until your blue in the face too...this will help sort it out.

g1smd

11:57 pm on Nov 4, 2002 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month




Does everyone use this [jigsaw.w3.org...] to check the CSS for errors. It is amazing how much incomplete or incorrect CSS now inhabits the web.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month