in Search
Welcome to Neopoleon - Sign in | Join | Help
Navigation: Home | Forums | Galleries

I'm not irrelevant to the geeks yet! Variables for CSS the Rory Way...

I haven't checked, but I think I've probably lost a lot of users over the past few months as I've gone from talking about tech occasionally to pretty much never. If I were to keep talking about tech all the time, it wouldn't be genuine. I'd be Scobeling my way to more inbound links. That mattered to me quite a bit in the past, and I played that you-link-to-me-and-I'll-link-to-you game. I don't play it anymore because it's one of the worst generators of noise on the net - my corner of it, anyway. If I link to you nowadays, it's because I really, really want to. I still usually find out about inbound links through Technorati, so it's not like I'm out there searching every blog in the universe for the things. Without Technorati, I probably wouldn't link out at all. Unless it was to people like Yuvi and Astrid, for example, who are highly creative, utterly bizarre people, both of whom I wish lived in my neighborhood.

I'm linking out today. Oh, yeah. You know it. Here it comes. Uh-huh. Booyah.

Back in March of 2004, I got sick of the voodoo of CSS. It was like this horrible declarative language (if that description is even remotely appropriate) designed with the aesthetics of Perl and implemented by HTML hackers (if "hackers" is even remotely appropriate). I hate it. I really, really, really, really, really hate it. Trying to find the sense of it is like alphabetizing your feces.

What I hated most was the insane lack of reusability. Unless you're a CSS apologist who's managed to find some amazing documentation out there that untangles just what in the hell the "Cascading" part of CSS means, you're going to use only just enough of CSS to get the job done. That's enough by itself to leave you with the QWERTY layout tattooed backwards on your face from all the pounding.

When I got tired of seeing the home row staring back at me when I looked in the mirror, I took it upon myself to commit the unholiest of acts possible in the hardcore, uptight, and pedantic world of the ubergeek.

As the title of the post indicates, I decided that blind adherence to standards, regardless of how vomitous the standardized tech in question might be, is limiting and, oh yeah, stupid.

I wrote a quick and dirty handler that was a rough go at adding variables to CSS. I used a syntax that was in the spirit of CSS. Ultimately, it was a simple find-and-replace job, but that simple find-and-replace job allowed me to use CSS in a way that didn't suck dog balls.

Follow this link to the original post if you're interested.

Since then, I've received one of the nicest geeky compliments I could hope for. When I put the handler together, I'll admit, I was disappointed at how much of a difference it didn't seem to make in other peoples' lives. A few people thought it was interesting, but there was minimal traction for the little guy.

In the past couple months, I've gotten email from a couple guys, both of whom were stoked about that old handler. These two guys - Troy Goode and Gabe Moothart - took the original, pushed it out to Codeplex, made improvements, and then threw in a couple bug fixes (the handler is so simple that there isn't a lot of room for bugs).

'Course, not everybody's so thrilled. Read the DotNetKicks comments on the story to meet the opposition. Not a lot of opposition, mind you, but representative of what I got back in 2004. I think my favorite comment is "This seems like something you shouldn't do." To the point, and well argued. Except, no. That's my argument in return.

On a little tangent, geeks are often so terrified of what they see as tangling with standards. Another comment in the DotNetKicks thread was: "Finding this while maintaining a project would be like finding cobol in an HTML file."

The hell it would. I won't argue with the analogy, as it's so disconnected from the way the handler works that it'd require a point by point explanation of what doesn't map rather than refuting the implicit arguments.

As was pointed out in the same thread, this handler outputs standard CSS. It's about as strange as an ASPX page (wherein, for the ol' record, as Ian could tell you [his top secret MySpace profile], it would be perfectly reasonable to find some Cobol).

If it helps you get the job done, and if it's documented, and if it's not especially complicated, then I don't see what's so bad about it. It's not like anybody else is going to stop CSS from sucking. If you want to see something not get done, then hand it to a committee.

Thassaboutit. Thanks, guys, for resurrecting this little bit of code. I was proud of it back when. It seemed like an easy way to help myself and anybody else with the backward-QWERTY-tattoo :)

Published Friday, November 23, 2007 6:36 PM by Rory

Filed Under: ,

Comments

 

Patrick said:

Ok, so maybe I'm a geek, but seriously... CSS isn't that hard.

Just: selector { thing: value; other-thing: value}

Where selector is something like: "p" or "body > p" or "p.magic" or "a#home-link" or ".rory, .other-rory, .super .magic .path .to #last-rory" or even just "#id" or ".class".

Maybe a lot of the magic is hiding in the selectors?
November 24, 2007 1:27 AM
 

Lloyd_Humph said:

I've definately started geeking up my blog now... and for those of you who know my full name, it's easy to find. for those who don't, it's lloydhumphreys.com ;)

Oh yeah, Rory. I just advertised in a comment. Except this comment wasn't the usual "here have a massive cock", but a nice, subtle advertisement.

0wn3d.
November 24, 2007 3:05 AM
 

Dave said:

Patrick: "CSS isn't that hard"

If everyone and his dog (on the internet nobody knows you're a dog) could get tables to work for formatting, but the same people have trouble with CSS, perhaps it's harder than you think?
November 24, 2007 4:39 PM
 

Patrick said:

Dave: "perhaps it's harder than you think?"

I never said it was easy (even if it was somewhat implied). Not hard, but not super easy.

Mostly CSS requires you to think more about what you're trying to do, when tables could only behave in a certain number of ways, so you could get away without thinking about it.
November 25, 2007 1:28 AM
 

Yuvi said:

Good reason I've never tried anything at web programming. To me, a server means a big, meaty box where I run big, meaty code that outputs big, meaty date. Unless, the new MVC framework out there and IIS7 extensions can change that...
November 25, 2007 4:58 PM
 

Mike said:

This looks like a pretty nice idea actually. It's just a bit of code generation at the end of the day. And if it makes it easier to code CSS, why not?
November 26, 2007 12:19 AM
 

Dave said:

Patrick: "Not hard, but not super easy"

Well, I disagree. There are literally thousands of articles kicking around out there of the form: "how to do ridiculously simple thing X using CSS". If CSS wasn't hard, those simple things would have easy and obvious solutions.

CSS is the best solution for the problem only because the alternatives are even worse. Tips like Rory's make life a lot easier for us mortals who think CSS is tricky at the best of times.
November 26, 2007 2:57 AM
 

paul said:

When was THIS blog about Tech?
November 26, 2007 8:03 AM
 

aristo said:

Heey.
It is true that lot of readers are tech guys... and you slowly loose them.
But it this a bad thing?
You left tech and became writer... So, your readers are different too. Nothing unexpected.
But... I won't say anything else because it will turn against me again, like before.

I wanted to mention something else.
Because of you I created my own blog... and I am happy about that. I don't know how often I will post something there and I still don't know how the shape of it should look like ( I mean, if it should be a tech blog, or the blog about everything or what) will see later.

You have my permission to visit it and post a comment (you will be the first, and the apprieciated one)

www.blog.aristo-samar.com

I just wanted to ask one question.
When are you gonna post something new on www.thesmartestman.com ?

I like it more than your blog. I don't mean anything wrong. The blog is fine, it is even more than fine. Creation story etc. but... www.thesmartest... is something special.

I just like it.

Mariusz
November 27, 2007 5:02 PM
 

Yuvi said:

Y'know, just thought I'll say it: The comments on the non-tech posts are far more fun to read. I just read my own comment here and almost puked...
November 27, 2007 6:04 PM
 

Celes said:

I admit, I haven't even read the post yet, I just saw that it had CSS as the title and thought that "Wow! That's so weird! I just was taking a break from working on the CSS in my site."  If you don't believe me, check my facebook page. I made some comment about Internet Explorer and CSS in my status.

But it just occurred to me, I bet a lot of people take breaks from writing CSS to read a Rory post... Probably even other, more complicated programming languages...

So, er, nevermind. I'll just crawl back into my artsy-psudo geek hole... right after I actually read the post... and maybe play a game on DOSbox... and hit Ctrl-F5 on Internet Explorer a few more times hoping something magical happens.

Now that I've read the post and comments- I have to say from current personal experience that part of the 'fun'/difficulty of css is not only css itself, it's the browsers and how they each have their own 'of life philosophies', wants, needs, and ways of making designers cry.

--It is true that lot of readers are tech guys... and you slowly loose them.

So what's this about tech guys getting lost or something? Well, take it from me, just pull over and ask for directions already, for crying out loud.

- Cindy -

November 27, 2007 6:15 PM
 

Rory said:

Patrick -

"Ok, so maybe I'm a geek, but seriously... CSS isn't that hard.

Just: selector { thing: value; other-thing: value}

Where selector is something like: "p" or "body > p" or "p.magic" or "a#home-link" or ".rory, .other-rory, .super .magic .path .to #last-rory" or even just "#id" or ".class".

Maybe a lot of the magic is hiding in the selectors?"

The most basic ideas of CSS aren't complicated, though the syntax really is. It's my feeling that, when you come to CSS from a coding background, you see something that's a far bigger mess than your programming language of choice, which, by the by, is certain to be a huge mess itself.

But in the same way a language like English has had bits tacked on and hacked over the years, you can't find the proper range of expression in a programming language without sacrificing aesthetics.

CSS, though - something like that is a great opportunity to do something clean. It's its own thing - you're not hacking on twenty year old Cobol.

So, the syntax for assignment is frustrating. It seems arbitrary (and may very well have been). It's ugly, and it's unclear. Organization of a CSS document can be, in some ways, very loose. It's like Latin - you can write a sentence in Latin with bizarre word order and it'll still be grammatically correct. Add to that the old Roman habit of pounding Latin into tablets without putting spaces between the words (spaces were fluff that would have made the medium less efficient), and you have something surpassing, though resembling, the frustration of interpreting CSS.

Like anything else, you can be meticulous with your layout and create a document that makes sense, but even with that goal, it's difficult not to dirty things up. CSS almost encourages it. I always tried to group like settings in areas delimited by comments, but when the file gets big, it's harder and harder to stick to that. I've never used a CSS editor that laid out the structure of a doc in a tree view in such a way that it corresponded to what I needed to see. Different editors, different approaches, and, unless there's one out there that's fantastic and that I've just missed (which is *very* likely), they just suck, and are probably built on the same ideas as CSS itself, which is to say Who Cares Where this Thing Goes or How We Represent It.

Repetition is another huge problem. When you're getting into the nitty-gritty of it all, the faux-inheritance of CSS isn't good enough. In fact, it's *so* voodoo and *so* overthought that it's easier to work without it. It's a terrible, terrible model, and one that hardly makes sense.

A clean XML based spec for doing stylesheets makes much more sense. Again, this stuff is probably out there and I just don't know about it (in fact, you could put together a relatively simple XSLT solution to turn XML into CSS, though I wouldn't want to be the one to do it).

In the end, I don't see any way to be productive with CSS on a large scale without building hacky scaffolding around it. Time is wasted searching for the right spot to put things down, and it's easy to duplicate your efforts because of the relative lack of structure in the document.

Kind of like reading Latin with no spaces.
November 28, 2007 7:03 PM
 

Rory said:

Lloyd -

"I've definately started geeking up my blog now... and for those of you who know my full name, it's easy to find. for those who don't, it's lloydhumphreys.com ;)

Oh yeah, Rory. I just advertised in a comment. Except this comment wasn't the usual "here have a massive cock", but a nice, subtle advertisement."

I've already cooked up my revenge.

I'm going to post a gratuitous link to your site in one of my upcoming posts so that you don't even have the chance to advertise here.

That'll learn you good.
November 28, 2007 7:04 PM
 

Rory said:

Dave -

"If everyone and his dog (on the internet nobody knows you're a dog) could get tables to work for formatting, but the same people have trouble with CSS, perhaps it's harder than you think?"

No kidding.

Setting style formatting is hard enough - positioning is a nightmare. From CSS itself to the many TOTALLY BUGGY implementations, there's nothing that says Screw This like scrapping all the "good design" and just throwing a bunch of tables in.

I love tables. It's unfashionable to love tables, but I don't think most people know why. I used to get lectured about this, but nobody ever argued the point, which is accessibility. Not one.

It was always, "Tables are bad because... CSS!"

And that's not an argument.

Solidarity, brother :)
November 28, 2007 7:06 PM
 

Rory said:

Mike -

"This looks like a pretty nice idea actually. It's just a bit of code generation at the end of the day. And if it makes it easier to code CSS, why not?"

See? Right on.

I don't see what's wrong with building a hack to hack a hack.

It doesn't even begin to solve the many problems with CSS (and, to be fair to CSS, the shoddy implementations), but it helps reduce the duplication of effort.

As long as you don't push the solution on other people, but let them make the choice, I think it's goodness :)
November 28, 2007 7:12 PM
 

Rory said:

aristo -

"I wanted to mention something else. Because of you I created my own blog... and I am happy about that."

I'll take that as a high compliment - thank you :)

"You have my permission to visit it and post a comment (you will be the first, and the apprieciated one)"

I checked it out and wanted to comment, but it wanted me to log in - I'll create an account to do so, because I actually wanted to respond to the post.

"I just wanted to ask one question. When are you gonna post something new on www.thesmartestman.com ?"

Tonight after midnight - I have a whole new format that I'm trying out, so it's going to be a different show, but one I like a lot. The show as it's been is just my posts read out loud, and I want to do something more interesting than that, because reading my own stuff isn't much fun.

Hope you like it...
November 28, 2007 7:16 PM
 

Rory said:

paul -

"When was THIS blog about Tech?"

A few years ago :)
November 28, 2007 7:17 PM
 

Rory said:

Yuvi -

"Y'know, just thought I'll say it: The comments on the non-tech posts are far more fun to read. I just read my own comment here and almost puked..."

I don't think your comment was puke-worthy, but it wasn't as fun as your other comments.

I guess we all need to be serious sometimes to balance things out and clear the palate.

With the YouTube videos, the latest (and new version) of The Smartest Man in the World, the second YouTube video that's going up on Friday, and the completion of the creation story next week (that's my plan), we'll have plenty of weirdness to play off of for a few days :)

I'm also putting together some Smartest Man in the World YouTube videos - they'll basically be commercials for the show, though not quite how you'd picture it. There's so much fun crap coming along. I just got off the phone with one of my co-conspirators, and the goodness that came out of that conversation tells me this stuff is going to be the awesome.

Yep.

You read it.

The awesome.

And I get to laugh because I'm working with two other people now, both of whom, I think, are funnier than I am. I'm just the slave-driver who's making them put their talents to use.

I feel good again - last week isn't bugging me so much now...
November 28, 2007 7:43 PM
 

Rory said:

Celes -

I've already responded to you by the electronic internet mailing system, so I won't reply to your comment here.

I just wanted to reply to it in a non-replying way so that you didn't think I wasn't replying.

That made so little sense.

You know what I mean.
November 28, 2007 7:44 PM
 

Yuvi said:

Hey, do I get a link I do what lloyd did here? I mean, well, I just invented the term "Roryism" (prior-art be damned). And, am writing a few posts that are "Roryism"(first one up). So, do I get a link?

P.S. I don't know Lloyd personally (or even impersonally). All I know is that he's the youngest 9er. Oh, and he has an HTML tutorial. And, yeah, he's 13. And, ofcourse, being a geek-with-inferiority-complex, I do wish that I had internet access when I was 13. Sigh. So, basically, Hi Lloyd!

December 1, 2007 7:45 AM
 

Rory - Neopoleon : Links and a Hardcore Christmas said:

December 1, 2007 5:10 PM
 

SquaredRoot said:

CssHandler: CSS   Variables
December 7, 2007 10:09 PM
New Comments to this post are disabled

About Rory

I *own* this site, you loser.