The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Do I need to use CSS

I am relatively new to web authoring.  All my web content is created on the fly; there are no static html files.  Do I necessarily need to use Cascading Style Sheets?  Or can I just generate the necessary formatting in the appropriate tags?

The way I view cascading style sheets is that they provide a mechanism to alter the entire appearance of a web site simply by making a few changes to the css files.  But because my content is generated on the fly I can just do this in source code.

One more assumption I make is that it only supports standard browsers (if I understand correctly css can be used to alter the appearance of a site for alternative devices such as pds/mobile).

Thanks.
New to Web Applications
Thursday, August 23, 2007
 
 
You don't have to use it but it will more than likely make your life easier.  Let's say the specs change all of a sudden  and you've got to radically alter the appearance of your site.  Would you rather:

a) Hunt down every single formatting blahblah scattered all over your codebase

or

b) Edit one file (that you include on every dynamically generated page).

To be sure, if you've got some one-off formatting requirement, not all of that has to be done in one monolithic  "sitewide.css", you can inline styles, inline formatting, whatever works for you, it's one of those equilibrium things that experience will give you an intuition for.  (My experience is that centralization of this stuff does lead to lesser long-term maintenance pain, but of course ymmv.)
son of anon
Friday, August 24, 2007
 
 
You should definitely use "CSS", the technology, to control the look/feel of your site. But there's no dire need for it to be in external files, if it's easier to simply write the CSS information into the HTML page. Is that what you're asking? (External files would decrease overall file size, though, if many of your pages share a common look/feel.)

Sorry if I'm not grasping what you're asking here. It sounds like you're viewing CSS as primarily a way to expedite managing a site's look/feel and customizing appearance on different platforms. It does do those things, but the real value to CSS lies in separating the information from the presentation, which may or may not be relevant to how you're making your web pages.

(There are other advantages to CSS as well; overall if you don't know/understand why you shouldn't be using it, you almost certainly should be.)
andy
Friday, August 24, 2007
 
 
CSS is just part of the equation. Many sites use images for their appearances, which can make things hard to change, so it's not as if using CSS all by itself is enough to change colors and so forth. No sir! I just saw a few sites that were hard on colorful images to present their "contents". :-) Folks like that somehow.

BTW, nowadays there are CSS "frameworks" that help you normalize your site. You should start with one of them because it helps to get your layouts done. For example, creating a layout without tables can be troublesome. But if you use one "framework" that does it for you, you can reuse one of them without much problem.

Another difference is that font names and sizes can differ from platform to platform, and with a "framework" you can try to keep things under control by resetting the default values to some normalized ones.

See for instance:
* http://developer.yahoo.com/yui/grids/

CSS is good, but it's not a definitive answer to the "presentation" all by itself.
Joao Pedrosa
Friday, August 24, 2007
 
 
Well, I think the OP's question is more along the lines of: if I'm writing all my HTML dynamically, and I only have one piece of coding writing the HTML for instances of X, then I already have only one piece of code to edit when I want to change the design of X. So what do I get out of using CSS?

And the answer is that single definitions of design information is only one of the things CSS has to offer. For one thing, do you really want design information - colors and fonts and so on - in your source code? Probably not, and the problem presented by that is precisely one of the things you use CSS for.
andy
Friday, August 24, 2007
 
 
If much of your formatting is in a css file used by all your pages the browser can cache that (I presume) and save the bandwidth of including it on every response.
AH
Friday, August 24, 2007
 
 
Indeed - it speeds up page rendering as well, if that's a factor, both because of the caching and because CSS generally renders faster than html (table) layouts.
andy
Friday, August 24, 2007
 
 
Another distinct advantage of using CSS files is that you can provide a variety of files with a variety of different styles so that users can switch to a different style on the fly. This also allows other inividuals to create additional CSS files which you can add to your library, all without changing a single line of code.
Tony Marston Send private email
Friday, August 24, 2007
 
 
To do it "correctly", yes, you need to use CSS. Most of the formatting tags in HTML (like "font", "b", "center") are deprecated. The correct way to do this is using style sheets.

There are several ways to use them, though. If you're concerned about the difficulty of including a separate file, and generating it on the fly, you can include the styles in your HTML page. You can put them all in a "style" tag at the top. Or you can generate "style" attributes on each tag that you want to change.
JW
Friday, August 24, 2007
 
 
Forgot to mention -- you also have many more formatting options using CSS.
JW
Friday, August 24, 2007
 
 
Yes.
John Doe Send private email
Friday, August 24, 2007
 
 
<<Well, I think the OP's question is more along the lines of: if I'm writing all my HTML dynamically, and I only have one piece of coding writing the HTML for instances of X, then I already have only one piece of code to edit when I want to change the design of X. So what do I get out of using CSS?>>

What Andy wrote is exactly what I am getting at. 

Question: what is the proper way to notify a browser in the event that your css files have changed and they need to refresh them?

Thanks for all your help.
New to Web Applications
Friday, August 24, 2007
 
 
>>
Question: what is the proper way to notify a browser in the event that your css files have changed and they need to refresh them?
>>

Remember, the CSS file is pulled, not pushed.  Your server should instruct the browser, via HTTP header, to not cache the CSS files for an excessively long amount of time.  Then you have to pray that the browser follows that advice and actually does a HEAD or GET to check for a new css file on a reasonably frequent basis, rather than just using the cached copy.  In general, browsers expect CSS files to be reasonably static so when I personally do web development I end up frequently having to do a hard reload of the page (shift-click the reload button, causes all resources to be reloaded).
Patrick McKenzie (Bingo Card Creator) Send private email
Saturday, August 25, 2007
 
 
Incidentally, an effective trick to get most browsers to ignore the freaking cache is described here:

http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/
Patrick McKenzie (Bingo Card Creator) Send private email
Saturday, August 25, 2007
 
 
You can also add the file timespamp to the url instead of version. I do this with automatically on all swf's as they are the most beligerent to refresh without cleaning the cache.
pgb
Wednesday, August 29, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz