Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: not2easy

Message Too Old, No Replies

Content Structure in the CSS document

     

corny

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

Inactive Member
Account Expired

 
 


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?

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 3, 2002
posts:1590
votes: 0


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).
4:07 pm on Nov 4, 2002 (gmt 0)

Senior Member

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

joined:Feb 4, 2002
posts:5044
votes: 0


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

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

Senior Member from US 

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

joined:Apr 27, 2001
posts:12166
votes: 51


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.
4:39 pm on Nov 4, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 15, 2002
posts:971
votes: 0


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.

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

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0



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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members