This page is no longer active

Da Blog has moved to MorganWick.com. Please update your bookmarks, links, and RSS readers.

Wednesday, August 1, 2007

My gripe with CSS

CSS allows you to have every format rule defined for later use (here "format"
means how things appear). So if you are writing a large website and you want a
consistent appearance for every title, sub-title, how examples of code appear,
how paragraphs are aligned, (I could go on, CSS covers a wide range of
presentation options) then CSS is the way to go.

Let's say you have a 1200 page website that took you months to complete. Your
current boss gets a promotion and another person fills his place. Your new boss
says to change the font, the size, the background, the appearance of tables,
etc. everywhere on your 1200-page site to comply with some corporate policy. If
you engineered your site appropriately with CSS, you could do this by editing
your CSS file that has all your appearance (format) rules in one place.
(Assuming you used linked stylesheets.)

Or you could do it the hard way, and hammer the appearance changes on each
and every of your 1200 pages. Remember sleep? Your constitutional rights allow
you to take the hard way (this is meant as humor, not an insult).

The above is taken from http://en.wikibooks.org/wiki/CSS_Programming. CSS is used by most modern web sites to give all pages on it a consistent look and feel, with all the information needed for formatting in a single file.

If it's so great for formatting, why isn't it so great for other things? Why should so many sites repeat the same info on every page for elements, like navigation, that are repeated on every page? Suppose, to take Wikibooks' example, you were told to add a new item to the navigation bar of the site. If the nav bar is in HTML (not Flash), you would have to "hammer the [navigation] changes on each and every of your 1200 pages."

I should, instead, be able to change a single piece of HTML or CSS and have the changes occur on all pages automatically. Instead, at best you have to rig up some Javascript to apply the changes.

What am I missing here? Is there some easy way to do this (please don't say "frames") that I (and evidently a number of others) don't know about? Is there some reason why formatting should be updated dynamically but other sitewide elements shouldn't? What's going on here?

1 comment:

Tangent128 said...

I know CSS allows some generated content (with :before and :after selectors), but I think it's limited to plain text and images, though maybe one could insert a flash thing or html document.

XSLT stylesheets allow you to add things like navbars, headers, or just about any type of content, but they are very confusing.

I agree mostly, CSS is very nice and simple, but sometimes what it leaves out is aggrivating. There's no obvious way to center blocks, for instance.