Ben Ward

CSS for designers

.

Here’s a question for web designers. It’s a bit of a clich� question and I’m not advocating it at all, I’m purely curious.

As a designer, do you think you would find CSS more intuitive if it had been XML based, rather than the syntax they did choose?

I ask because it’s on my mind and I’m curious (especially in light of Andy Clarke’s comment at @media about CSS not being as easy for designers as the programmers who invented it).

For example, rather than writing:

p {<br />  font-family: "Lucida Grande", sans-serif;<br />}
strong, em {<br />  color: green;<br />}

What if you could write:
&lt;style><br />&lt;applyto>p&lt;/applyto><br />  &lt;font family="'Lucida Grande', sans-serif"><br />&lt;/style>
&lt;style><br />  &lt;applyto>strong&lt;applyto><br />  &lt;applyto>em&lt;/applyto><br />  &lt;font color="green"><br />&lt;/style>

Of course, ‘applyto’ could be named ‘selector’, properties could all be standalone elements rather than the element/attribute I picked vaguely at random above. My question concerns whether you think you’d have found CSS easier to pick up and work with if you had a syntax which was ultimately beared more simility to HTML.

To re-emphasise, I’m not saying that CSS should change, or that the real CSS syntax is in any specific way inferior or anything controvertial like that. But if you could choose, which would you use? This is the kind of question that probably gets a certain type of person very upset, sorry about that.

Comments

Previously, I hosted responses and commentary from readers directly on this site, but have decided not to any more. All previous comments and pingbacks are included here, but to post further responses, please refer me to a post on your own blog or other network. See instructions and recommendations of ways to do this.

  1. I think an xml based solution would be less intuitive, for the simple reason that you end up with a)more lines of code for any given rule and b)more characters in each rule which are pulely syntactic.

    I’m gonna go out on a limb here and say that it’s not CSS which is difficult to adapt to but code in general, and a way of thinking that facilitates coding.

  2. I’m going to go with Elly in saying it would be less intuitive in XML, plus I’m going to add the reason that I can see much confusion arising when your content and your presentation description look very much the same (i.e. lots of angle-brackets everywhere).

  3. I think one of the easy things about learning (X)HTML and CSS, was that they differed. This might sound contradictory, but it helps in this whole “separation of mark-up and style”-thing.

    But at the moment, I’m not sure. I love the XML-format due to its simplicity, but I’m not sure if it would be easier/more intuitive to write my styles in it.

  4. Ben

    I’m going to chip in with broad agreement. I asked the question at a time that I didn’t really have an answer of my own, so it’s been interesting to have my response influenced by all of your before me.

    One thing first: ‘Addressing’ the question to designers might have seemed a tad exclusive or odd. The reason is because it is targeted at people who are, often, less techy (or at least the less techy sides of techy people). People who may be less likely to comfortably recognise ‘{’ from programming languages, for example. It wasn’t the best way to word it, really, but I hope you see why existing programmers are more likely to be comfortable with CSS’s braces and semi-colon filled.

    Anyway. Being a programmer and being perfectly comfortable with XML and CSS, I’m quite happy with the CSS syntax as it is. I very much agree with Jonathan, though. Whilst having different syntax is a very blunt way of emphasising a difference, XML-CSS would suffer from some fundamental confusion issues (if elements were named sensibly). Another &lt;font&gt; tag? Another <style> tag? Although technically different from their HTML namesakes (XML namespaces make them different), from a learner’s point of view (or as someone trying to teach) the confusion would be mind exploding.

    I guess the answer was pretty obvious, but I was curious to see if anyone would say ‘yes’.

You can file issues or provide corrections: View Source on Github. Contributor credits.