473,657 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing maintainable stylesheets

I've been thinking about writing CSS that's easy to read and adjust at a
later date (often by someone else).

Here's where I seem to be headed:

Breaking the page down into container divs, setting a class for each of them
like:

..header, .left_column, .main_content ,.right_column, .footer, .nav

(maybe not those names, but obvious ones)

creating very few other classes, instead styling like this:

..header p{...}
..header p img{...}

no @import , NS4 readble but not necessarily beautiful.
Checking IE5,Opera7, NS7.1 and Safari. (Usually nearly identical)

Everything external, but few stylesheets. Usually just one site wide, but
that may because I'm doing static (CMS) and database pages using the same
template for both.

Where are we headed with maintainability ? What approaches are being used
that are successfull? What am I doing that may be wrong? What is right?

I'm just a programmer, so I don't have much experience with this. But I find
myself writing more and more templates lately as many webdevelopers need
cleaner, more precise HTML than you can write with Dreamweaver! Oh what
tangled tables I've disposed of!

Jeff

Jul 20 '05 #1
6 2009
On Mon, 09 Feb 2004 06:39:44 GMT, Jeff Thies <no****@nospam. net> wrote:
I've been thinking about writing CSS that's easy to read and adjust at a
later date (often by someone else).

Here's where I seem to be headed:

Breaking the page down into container divs, setting a class for each of
them
like:

.header, .left_column, .main_content ,.right_column, .footer, .nav

(maybe not those names, but obvious ones)
I don't know about others, but I find using ID's for major divisions of a
page is easier, and lends itself to easy organization.
creating very few other classes, instead styling like this:

.header p{...}
.header p img{...}
Right, and sorting under the div they go with.
no @import , NS4 readble but not necessarily beautiful.
Well, I prefer a link to common styles and importing styles that won't mix
with older browsers. Not the only way to do it, of course.
Checking IE5,Opera7, NS7.1 and Safari. (Usually nearly identical)

Everything external, but few stylesheets. Usually just one site wide, but
that may because I'm doing static (CMS) and database pages using the same
template for both.
External is a given. Internal is as hard to maintain as doing it the old
way.
Where are we headed with maintainability ? What approaches are being used
that are successfull? What am I doing that may be wrong? What is right?

I'm just a programmer, so I don't have much experience with this. But I
find
myself writing more and more templates lately as many webdevelopers need
cleaner, more precise HTML than you can write with Dreamweaver! Oh what
tangled tables I've disposed of!


An external CSS or two (one imported into the linked file) are so much
easier to alter, adjust and maintain than a site full of style.
Occasionally, you have to go thru each page and alter the structure,
adding or moving a div, but that's quick work. Far easier than
finding/replacing a formatting change in every document whether it has it
or not.

I keep a txt template (current to the latest format) in with the local
files. Everything but content is there, makes new page generation simple.
Jul 20 '05 #2
> > I've been thinking about writing CSS that's easy to read and adjust at a
later date (often by someone else).

Here's where I seem to be headed:

Breaking the page down into container divs, setting a class for each of
them
like:

.header, .left_column, .main_content ,.right_column, .footer, .nav

(maybe not those names, but obvious ones)
I don't know about others, but I find using ID's for major divisions of a
page is easier, and lends itself to easy organization.


Hmmm, that may be easier to pick up the major divisions as an ID, #'s really
standout. I rarely use id's in stylesheets anyhow.

Might be a good idea to add some whitespace in between stylesheet "sections"
and add comments about the architecture. I've never seen that though!

<snip>
I keep a txt template (current to the latest format) in with the local
files. Everything but content is there, makes new page generation simple.


Good idea. I usually have a templates folder. (with one or two templates)

Cheers,
Jeff
Jul 20 '05 #3
On Mon, 09 Feb 2004 01:56:12 -0500, Neal wrote:
On Mon, 09 Feb 2004 06:39:44 GMT, Jeff Thies <no****@nospam. net> wrote:
I've been thinking about writing CSS that's easy to read and adjust at a
later date (often by someone else).

Here's where I seem to be headed:

Breaking the page down into container divs, setting a class for each of
them
like:

.header, .left_column, .main_content ,.right_column, .footer, .nav

(maybe not those names, but obvious ones)


I don't know about others, but I find using ID's for major divisions of a
page is easier, and lends itself to easy organization.


I agree with using IDs instead of classes for this. However, I would argue
that some of the names above are not good. In particular, left_column and
right_column. Instead, use names that describe what is in them. (header,
footer, nav are all good for this reason.) What you want to avoid is a
situation where you end up doing a redesign where what used to appear on
the left now appears on the right, but is still named left.
creating very few other classes, instead styling like this:

.header p{...}
.header p img{...}


Right, and sorting under the div they go with.


I'm not sure if this is what you mean, but I often try to style things with
whichever of child, descendant, and adjacent-sibling selectors is most
appropriate, rather than defining new classes. For example, if I want a
particular style on the headings of the content div, I'd use #content>h1
rather than .content_header . Of course there are lots of good times to use
classes, but they seem to be used by many people as a catch-all method,
when some other way is often cleaner.
no @import , NS4 readble but not necessarily beautiful.


Well, I prefer a link to common styles and importing styles that won't mix
with older browsers. Not the only way to do it, of course.


Agreed. The only variant on this that I use is that my script for header
generation detects MSNTV and doesn't give them the @import, because they
try to use it, but tend to botch things up royally due to very broken CSS
support.
Checking IE5,Opera7, NS7.1 and Safari. (Usually nearly identical)

Everything external, but few stylesheets. Usually just one site wide, but
that may because I'm doing static (CMS) and database pages using the same
template for both.


External is a given. Internal is as hard to maintain as doing it the old
way.


Agreed again, although there are a couple of isolated instances where I
need a style in only a single place so I inline it.

--
Greg Schmidt gr***@trawna.co m
Trawna Publications http://www.trawna.com/
Jul 20 '05 #4
On Sun, 15 Feb 2004 04:43:30 GMT, Greg Schmidt <gr***@trawna.c om> wrote:
Agreed again, although there are a couple of isolated instances where I
need a style in only a single place so I inline it.

That's certainly appropriate on occasion. Still, you'll agree that the
average web author will want to have an external .css document contain
almost every style. I'd advise a beginner who has worked out their style
sheet in the header for one page to clip it and make an external css file
before beginning page 2. The instances where an inline style or a
permanent page-specific head style declaration are actually worthwhile
take a bit of time to recognize.
Jul 20 '05 #5
It seems "Greg Schmidt" wrote in
comp.infosystem s.www.authoring.stylesheets:
However, I would argue
that some of the names above are not good. In particular, left_column and
right_column . Instead, use names that describe what is in them. (header,
footer, nav are all good for this reason.)


Just out of curiosity, aren't "header" and "footer" just as
positionally named as "left" and "right"?

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #6
It seems "Neal" wrote in comp.infosystem s.www.authoring.stylesheets:
On Sun, 15 Feb 2004 04:43:30 GMT, Greg Schmidt <gr***@trawna.c om> wrote:
Agreed again, although there are a couple of isolated instances where I
need a style in only a single place so I inline it.


That's certainly appropriate on occasion. Still, you'll agree that the
average web author will want to have an external .css document contain
almost every style.


I agree. I know that pretty much every time I've created a style in
line, or even in a <head><style> section, I've very quickly found I
needed it in another document. Then I have to do (a bit) more work
than if I had put it in the style sheet to begin with.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #7

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

Similar topics

6
2507
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: twice a week (mondays and thursdays) Last-modified: March 10, 2001 Version: 1.95 URL: http://css.nu/faq/ciwas-mFAQ.html Maintainer: Jan Roland Eriksson <rex@css.nu> comp.infosystems.www.authoring.stylesheets FAQ v1.95 ______________________________________________________________________
2
2740
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson <rex@css.nu> comp.infosystems.www.authoring.stylesheets meta-FAQ v2.00 _______________________________________________________________________
0
1642
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson <rex@css.nu> comp.infosystems.www.authoring.stylesheets meta-FAQ v2.00 _______________________________________________________________________
0
2088
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson <rex@css.nu> comp.infosystems.www.authoring.stylesheets meta-FAQ v2.00 _______________________________________________________________________
17
7672
by: Eric Lindsay | last post by:
Is learning to write CSS a better use of time than finding and using a package that produces complete web pages? I've moved to a new platform (Macintosh), taking with me about 400 personal web pages, some dating back so far I probably wrote them in vi. About 4 years ago (thanks in part to hints found in this group) I converted about 80 pages to CSS, and was fairly happy with the result, plain though they are. Since then I've forgotten...
22
2705
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at programming. I tend to learn what is useful and gets the job done. I am always curious if there is some techique I don't know. I read books and study as well as write programs. My goal is to some day be able to get a job programming. I have a...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.