<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CSS variables considered harmful?</title>
	<atom:link href="http://ajaxian.com/archives/css-variables-considered-harmful/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/css-variables-considered-harmful</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: cheba</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266970</link>
		<dc:creator>cheba</dc:creator>
		<pubDate>Wed, 27 Aug 2008 17:58:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266970</guid>
		<description>Use SASS if you definitely need those variables.</description>
		<content:encoded><![CDATA[<p>Use SASS if you definitely need those variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IFlyHigh</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266552</link>
		<dc:creator>IFlyHigh</dc:creator>
		<pubDate>Sat, 09 Aug 2008 22:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266552</guid>
		<description>I&#039;m the author of the PHP version.

I just want to correct some incorrect assumptions about how it works.

It doesn&#039;t process it every time, it only will process if the css stylesheet has changed, and there is a command line compiler so you can precompile everything.

The PHP version actually is built to the same spec that the webkit version is, the stylesheets are interchangable.  I implemented it this way so that when browsers catch up, those stylesheets would be usable without change.

The one difference between my implementation and the spec, however, is that I have an eval() that lets you do stuff like:

padding: eval(variable / 2);
margin: eval((anothervariable / 2) * yetanother);

Honestly, I don&#039;t give a shit if people use it or not, we use it at massify.com and have found it an incredible boon to productivity in regards to how we build some very complicated pages and keep consistency across the entire site.  YMMV.

Best,

Jon.</description>
		<content:encoded><![CDATA[<p>I&#8217;m the author of the PHP version.</p>
<p>I just want to correct some incorrect assumptions about how it works.</p>
<p>It doesn&#8217;t process it every time, it only will process if the css stylesheet has changed, and there is a command line compiler so you can precompile everything.</p>
<p>The PHP version actually is built to the same spec that the webkit version is, the stylesheets are interchangable.  I implemented it this way so that when browsers catch up, those stylesheets would be usable without change.</p>
<p>The one difference between my implementation and the spec, however, is that I have an eval() that lets you do stuff like:</p>
<p>padding: eval(variable / 2);<br />
margin: eval((anothervariable / 2) * yetanother);</p>
<p>Honestly, I don&#8217;t give a shit if people use it or not, we use it at massify.com and have found it an incredible boon to productivity in regards to how we build some very complicated pages and keep consistency across the entire site.  YMMV.</p>
<p>Best,</p>
<p>Jon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jfw</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266550</link>
		<dc:creator>jfw</dc:creator>
		<pubDate>Sat, 09 Aug 2008 10:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266550</guid>
		<description>@ialexi(alex)

I like your idea. An inheritance possibility in CSS would make everything easier. I have been thinking about this as well. However, let&#039;s call this pseude attribute import, merge, use or mixin. Caling them classes or 00 inheritance in CSS often confuses people because they think that you want to implement complex OOP concepts whereas we only want to achieve something simple: namely, the overlay/overwrite (top-down) of CSS class attributes using a CSS selector for a different CSS class in a CSS document.

Many people say that we already have this in CSS, which is basically true (whitespace seperated class name list). However, the inheritance definition is shifted from the CSS document into the HTML document. Which means that, if I want to achieve a relatively strong abstraction of CSS styles in CSS, I have a long list of class names in the HTML document element class attricute. Firstly, the document gets too large and secondly, one always has to remember the whole chain of the inheritance hierarchy.

Especially the latter causes lots of trouble. We have two or more people working on the CSS/HTML at the same time, and each of them needs to have a good overview of the CSS definitions and has to speak often to the other developers, otherwise, they define things twice which is unnecessary. In large projects, it is almost impossible to keep a clean CSS in the long run.

On the other hand, you would put the inheritance (merge, mixin, import) back into the CSS document if you worked according to the blackbox principle as a developer. I only have to know the base classes (definitions), I can import/mixin/merge this base class to my new class and overwrite only the necessary attributes in this new class. In the end. I only have to know thes one new special style class and I can hand it over to other develpers. Then, they can overwrite the class again. 	furthermore you achieved an improved recycling of style definitions.

I hope all cann follow me. I&#039;m not a native english speaker.</description>
		<content:encoded><![CDATA[<p>@ialexi(alex)</p>
<p>I like your idea. An inheritance possibility in CSS would make everything easier. I have been thinking about this as well. However, let&#8217;s call this pseude attribute import, merge, use or mixin. Caling them classes or 00 inheritance in CSS often confuses people because they think that you want to implement complex OOP concepts whereas we only want to achieve something simple: namely, the overlay/overwrite (top-down) of CSS class attributes using a CSS selector for a different CSS class in a CSS document.</p>
<p>Many people say that we already have this in CSS, which is basically true (whitespace seperated class name list). However, the inheritance definition is shifted from the CSS document into the HTML document. Which means that, if I want to achieve a relatively strong abstraction of CSS styles in CSS, I have a long list of class names in the HTML document element class attricute. Firstly, the document gets too large and secondly, one always has to remember the whole chain of the inheritance hierarchy.</p>
<p>Especially the latter causes lots of trouble. We have two or more people working on the CSS/HTML at the same time, and each of them needs to have a good overview of the CSS definitions and has to speak often to the other developers, otherwise, they define things twice which is unnecessary. In large projects, it is almost impossible to keep a clean CSS in the long run.</p>
<p>On the other hand, you would put the inheritance (merge, mixin, import) back into the CSS document if you worked according to the blackbox principle as a developer. I only have to know the base classes (definitions), I can import/mixin/merge this base class to my new class and overwrite only the necessary attributes in this new class. In the end. I only have to know thes one new special style class and I can hand it over to other develpers. Then, they can overwrite the class again. 	furthermore you achieved an improved recycling of style definitions.</p>
<p>I hope all cann follow me. I&#8217;m not a native english speaker.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JeromeLapointe</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266538</link>
		<dc:creator>JeromeLapointe</dc:creator>
		<pubDate>Fri, 08 Aug 2008 18:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266538</guid>
		<description>@TNO
Well your first link basically says CSS is too complicated for designers. That maybe but then adding variables would not simplify things for them (nor making it JS like)... but CSS is not a design tool either. No wysiwyg editor will ever put out sensible code anyways.... independently of the language that&#039;s running behind it.

Your 3 last link are really just disputing the role of CSS as a layout language... which is an old debate that basically comes down to columns. It always seems accompanied with a nostalgia for the old days of table layouts. Table design is a failure. There is room for bringing columns to CSS, it just needs to get implemented.

In any case the people who have a problem with CSS for layouts usually want to add another layer of tech... which does nothing to bring all the &quot;mental eggs in one language basket&quot; as you say.

Getting back on topic.
It seems to me (I may be wrong) that the main request for CSS constants (or variables) comes from app builders who want a more dynamic CSS for their widgets and apps. I get that, but it&#039;s very specific. It gets even more specific when you realize most of them are talking about colors and nothing else. In fact in most cases, you could use constants to accomplish the same thing.

As I was saying earlier, most browsers support the &quot;named colors&quot; and &quot;system colors&quot;. The W3C refers to them as keywords.
http://www.w3.org/TR/CSS21/syndata.html#keywords
&quot;A  is either a keyword or a numerical specification.&quot;

What would be cool is if you could declare your own &quot;keywords&quot;.
I can already go:
.myApp{color:redbrick;}
.myApp{background:ButtonFace;}

so why not simply allow me to do:
@colors{myAppBasetone:#FF0099;}
.myApp{background:myAppBasetone,#F09;}

(notice the &quot;font-family style&quot; backup color)
This is something they could add to SVG &amp; Canvas as well.</description>
		<content:encoded><![CDATA[<p>@TNO<br />
Well your first link basically says CSS is too complicated for designers. That maybe but then adding variables would not simplify things for them (nor making it JS like)&#8230; but CSS is not a design tool either. No wysiwyg editor will ever put out sensible code anyways&#8230;. independently of the language that&#8217;s running behind it.</p>
<p>Your 3 last link are really just disputing the role of CSS as a layout language&#8230; which is an old debate that basically comes down to columns. It always seems accompanied with a nostalgia for the old days of table layouts. Table design is a failure. There is room for bringing columns to CSS, it just needs to get implemented.</p>
<p>In any case the people who have a problem with CSS for layouts usually want to add another layer of tech&#8230; which does nothing to bring all the &#8220;mental eggs in one language basket&#8221; as you say.</p>
<p>Getting back on topic.<br />
It seems to me (I may be wrong) that the main request for CSS constants (or variables) comes from app builders who want a more dynamic CSS for their widgets and apps. I get that, but it&#8217;s very specific. It gets even more specific when you realize most of them are talking about colors and nothing else. In fact in most cases, you could use constants to accomplish the same thing.</p>
<p>As I was saying earlier, most browsers support the &#8220;named colors&#8221; and &#8220;system colors&#8221;. The W3C refers to them as keywords.<br />
<a href="http://www.w3.org/TR/CSS21/syndata.html#keywords" rel="nofollow">http://www.w3.org/TR/CSS21/syndata.html#keywords</a><br />
&#8220;A  is either a keyword or a numerical specification.&#8221;</p>
<p>What would be cool is if you could declare your own &#8220;keywords&#8221;.<br />
I can already go:<br />
.myApp{color:redbrick;}<br />
.myApp{background:ButtonFace;}</p>
<p>so why not simply allow me to do:<br />
@colors{myAppBasetone:#FF0099;}<br />
.myApp{background:myAppBasetone,#F09;}</p>
<p>(notice the &#8220;font-family style&#8221; backup color)<br />
This is something they could add to SVG &amp; Canvas as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ialexi</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266530</link>
		<dc:creator>ialexi</dc:creator>
		<pubDate>Fri, 08 Aug 2008 12:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266530</guid>
		<description>@LeoHorie But what I suggested was not quite object-oriented-programming-style inheritance. I suggested being able to &quot;import&quot; one style into another, creating an effect &lt;em&gt;similar&lt;/em&gt; to inheritance, but not actually inheritance.

I realize that stylesheets are collections of queries, and as such, perhaps the &quot;inherit&quot; statement should allow the use of another selector, rather than a &quot;class definition&quot; as I called it earlier. This has a large potential for abuse, but a large potential for proper usage. It would run something like this:

&lt;code&gt;
.myBaseSelector
{
color: white;
}

.myBaseSelector div
{
backgroundColor: &quot;black&quot;
}

.myNewSelector
{
inherit: .myBaseSelector;
/* BAD (but valid) USE: */
inherit: .myBaseSelector div;
}

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>@LeoHorie But what I suggested was not quite object-oriented-programming-style inheritance. I suggested being able to &#8220;import&#8221; one style into another, creating an effect <em>similar</em> to inheritance, but not actually inheritance.</p>
<p>I realize that stylesheets are collections of queries, and as such, perhaps the &#8220;inherit&#8221; statement should allow the use of another selector, rather than a &#8220;class definition&#8221; as I called it earlier. This has a large potential for abuse, but a large potential for proper usage. It would run something like this:</p>
<p><code><br />
.myBaseSelector<br />
{<br />
color: white;<br />
}</p>
<p>.myBaseSelector div<br />
{<br />
backgroundColor: "black"<br />
}</p>
<p>.myNewSelector<br />
{<br />
inherit: .myBaseSelector;<br />
/* BAD (but valid) USE: */<br />
inherit: .myBaseSelector div;<br />
}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joeri</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266529</link>
		<dc:creator>Joeri</dc:creator>
		<pubDate>Fri, 08 Aug 2008 11:09:49 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266529</guid>
		<description>@LeoHorie: my point was that if dynamically generating a stylesheet is so simple, everyone would be doing it. You need a design-time build system, or you have a run-time overhead from starting the interpreter. Both of those are so non-ideal that neither is in common use.

Really, css variables are the cleanest solution to the problem of reusable style definitions. Why is that such a hard concept to grasp?</description>
		<content:encoded><![CDATA[<p>@LeoHorie: my point was that if dynamically generating a stylesheet is so simple, everyone would be doing it. You need a design-time build system, or you have a run-time overhead from starting the interpreter. Both of those are so non-ideal that neither is in common use.</p>
<p>Really, css variables are the cleanest solution to the problem of reusable style definitions. Why is that such a hard concept to grasp?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TNO</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266526</link>
		<dc:creator>TNO</dc:creator>
		<pubDate>Fri, 08 Aug 2008 00:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266526</guid>
		<description>@JeromeLapointe:

I&#039;m not saying we should run back to the original specification of JSSS, but I think the current concept has too many flaws, and too much complexity already. I don&#039;t want to get off topic, so here&#039;s a few links that describe the problems pretty well I think: 

http://www.cybergrain.com/archives/2004/12/css_considered.html
http://www.accidentalscientist.com/2007/07/css-sucks-for-layout.html
http://www.nczonline.net/blog/2007/10/8/css_sucks
http://gui.net/blog/2006/12/15/why-css-sucks/
...and the list goes on</description>
		<content:encoded><![CDATA[<p>@JeromeLapointe:</p>
<p>I&#8217;m not saying we should run back to the original specification of JSSS, but I think the current concept has too many flaws, and too much complexity already. I don&#8217;t want to get off topic, so here&#8217;s a few links that describe the problems pretty well I think: </p>
<p><a href="http://www.cybergrain.com/archives/2004/12/css_considered.html" rel="nofollow">http://www.cybergrain.com/archives/2004/12/css_considered.html</a><br />
<a href="http://www.accidentalscientist.com/2007/07/css-sucks-for-layout.html" rel="nofollow">http://www.accidentalscientist.com/2007/07/css-sucks-for-layout.html</a><br />
<a href="http://www.nczonline.net/blog/2007/10/8/css_sucks" rel="nofollow">http://www.nczonline.net/blog/2007/10/8/css_sucks</a><br />
<a href="http://gui.net/blog/2006/12/15/why-css-sucks/" rel="nofollow">http://gui.net/blog/2006/12/15/why-css-sucks/</a><br />
&#8230;and the list goes on</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LeoHorie</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266525</link>
		<dc:creator>LeoHorie</dc:creator>
		<pubDate>Fri, 08 Aug 2008 00:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266525</guid>
		<description>&gt;&gt; If caching it on disk was that simple, we would all be doing it. 

@Joeri: Well, we &lt;em&gt;are&lt;/em&gt; doing it, or at least we should be. We can only serve static CSS content, so I really don&#039;t see any reason to dynamically generate a different stylesheet for every page. The YSlow performance tips go into the details fairly well.

As for aliasing, like take mentioned (e.g. CustomRed = #ff0010), it can be pre-processed and cached fairly easily... The code to do it with PHP is just a dozen of lines long, if that.

@ialexi: you&#039;re right, &lt;em&gt;OOP-style&lt;/em&gt; inheritance isn&#039;t possible in CSS because it&#039;s not a object oriented language in the first place. Stylesheets are a bunch of &lt;em&gt;queries&lt;/em&gt;, and the &lt;em&gt;objects&lt;/em&gt; to which the queries apply live in the HTML. I consider CSS much more similar to SQL UPDATEs than to Java.</description>
		<content:encoded><![CDATA[<p>&gt;&gt; If caching it on disk was that simple, we would all be doing it. </p>
<p>@Joeri: Well, we <em>are</em> doing it, or at least we should be. We can only serve static CSS content, so I really don&#8217;t see any reason to dynamically generate a different stylesheet for every page. The YSlow performance tips go into the details fairly well.</p>
<p>As for aliasing, like take mentioned (e.g. CustomRed = #ff0010), it can be pre-processed and cached fairly easily&#8230; The code to do it with PHP is just a dozen of lines long, if that.</p>
<p>@ialexi: you&#8217;re right, <em>OOP-style</em> inheritance isn&#8217;t possible in CSS because it&#8217;s not a object oriented language in the first place. Stylesheets are a bunch of <em>queries</em>, and the <em>objects</em> to which the queries apply live in the HTML. I consider CSS much more similar to SQL UPDATEs than to Java.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HudsonTavares</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266523</link>
		<dc:creator>HudsonTavares</dc:creator>
		<pubDate>Thu, 07 Aug 2008 21:09:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266523</guid>
		<description>Double-posting, again:
How much similarity is shared between a language resource and programming languages from completely different levels?</description>
		<content:encoded><![CDATA[<p>Double-posting, again:<br />
How much similarity is shared between a language resource and programming languages from completely different levels?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HudsonTavares</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266522</link>
		<dc:creator>HudsonTavares</dc:creator>
		<pubDate>Thu, 07 Aug 2008 21:08:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266522</guid>
		<description>@tack: I agree that sometimes, in some use cases, a CSS var could be very suitable.

However, I disagree at the point you said &quot;it&#039;s common to have 3000 lines of CSS code&quot;; I&#039;m doing nice / responsive / complete sites using less than 400 (the site that is opened right now on my Dreamweaver&#039;s window have less than 200) lines.

Your site&#039;s complexity / size might not be (and very, very often, isn&#039;t) proportional to the amount of CSS styles you have to write.

@tlrobinson:
You&#039;ve got this phrase out of it&#039;s context. The complete paragraph says:

&quot;The other implementation is written in PHP. It proves that it is not necessary to add constants to CSS. Just like the existence of the WebKit implementation cannot be taken as proof that constants in CSS are useful, so the PHP implementation cannot prove that either. But the PHP implementation has the benefit of letting authors determine the usefulness for themselves, without modifying CSS on the Web.&quot;

BTW, LOL, hyperbolic example.

How much similarity is shared between a language resource and programming languages from completely different levels you see?</description>
		<content:encoded><![CDATA[<p>@tack: I agree that sometimes, in some use cases, a CSS var could be very suitable.</p>
<p>However, I disagree at the point you said &#8220;it&#8217;s common to have 3000 lines of CSS code&#8221;; I&#8217;m doing nice / responsive / complete sites using less than 400 (the site that is opened right now on my Dreamweaver&#8217;s window have less than 200) lines.</p>
<p>Your site&#8217;s complexity / size might not be (and very, very often, isn&#8217;t) proportional to the amount of CSS styles you have to write.</p>
<p>@tlrobinson:<br />
You&#8217;ve got this phrase out of it&#8217;s context. The complete paragraph says:</p>
<p>&#8220;The other implementation is written in PHP. It proves that it is not necessary to add constants to CSS. Just like the existence of the WebKit implementation cannot be taken as proof that constants in CSS are useful, so the PHP implementation cannot prove that either. But the PHP implementation has the benefit of letting authors determine the usefulness for themselves, without modifying CSS on the Web.&#8221;</p>
<p>BTW, LOL, hyperbolic example.</p>
<p>How much similarity is shared between a language resource and programming languages from completely different levels you see?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tlrobinson</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266519</link>
		<dc:creator>tlrobinson</dc:creator>
		<pubDate>Thu, 07 Aug 2008 20:36:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266519</guid>
		<description>&quot;This PHP version proves that it is not necessary to add constants to CSS. &quot;

This is a ridiculous claim. It&#039;s like saying there&#039;s no use for higher level programming languages (or CSS for that matter) because I can just write assembly.</description>
		<content:encoded><![CDATA[<p>&#8220;This PHP version proves that it is not necessary to add constants to CSS. &#8221;</p>
<p>This is a ridiculous claim. It&#8217;s like saying there&#8217;s no use for higher level programming languages (or CSS for that matter) because I can just write assembly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tack</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266516</link>
		<dc:creator>tack</dc:creator>
		<pubDate>Thu, 07 Aug 2008 19:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266516</guid>
		<description>variable scope:  This is one of the cases where global variables are a desired functionality.  We aren&#039;t doing processing here.  We aren&#039;t worried about function A overwriting a global then function B breaking.  Everything should be static.  That being said, being able to specify a variable in the styles for div#myWidget so that div#myWidget p can use it but, say body can&#039;t should be all the localization we need.  I don&#039;t see a case for doing object/class inheritance in css.  This isn&#039;t OO programming.  This is describing style rules.  Even though we&#039;re skilled in the fine art of using a hammer, this is no nail, it&#039;s a screw.  And we should leave those techniques to the processing side of things (js and backend)</description>
		<content:encoded><![CDATA[<p>variable scope:  This is one of the cases where global variables are a desired functionality.  We aren&#8217;t doing processing here.  We aren&#8217;t worried about function A overwriting a global then function B breaking.  Everything should be static.  That being said, being able to specify a variable in the styles for div#myWidget so that div#myWidget p can use it but, say body can&#8217;t should be all the localization we need.  I don&#8217;t see a case for doing object/class inheritance in css.  This isn&#8217;t OO programming.  This is describing style rules.  Even though we&#8217;re skilled in the fine art of using a hammer, this is no nail, it&#8217;s a screw.  And we should leave those techniques to the processing side of things (js and backend)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tack</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266515</link>
		<dc:creator>tack</dc:creator>
		<pubDate>Thu, 07 Aug 2008 19:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266515</guid>
		<description>I&#039;ve wanted variables in css for at least 8 years.  Simply put, going from the font tag everywhere to being able to style p&#039;s was a huge improvement.  I could alter the style for all the p&#039;s in one place.  But in css itself we still have the &#039;font tags everywhere&#039; problem where we&#039;re trying to implement colors from a style guide.  Say body text, input borders and nav background are #333.  That&#039;s 3 sets of selectors and rules I have to set up for 1 piece of data.  If the styleguide says those 3 things will always be the same color, even if that color changes, I should be able to set that color in one place.  It sounds as if Bert is coming from more of a CS background than a design background with this argument.  Styleguides have constants.  One of their primary functions is the expression of constants.  And having to hard code values all over the place is a major shortcoming of css as a style language.  Maybe not so big a deal if you&#039;ve got 30 lines of code in your styles.  But it&#039;s common for our projects to have 3000 lines of code in styles.  Also, php and javascript aren&#039;t viable workarounds all the time.  Sometimes you don&#039;t have javascript available to you.  Sometimes it&#039;s a flat site and you can&#039;t have a backend.  And even if you could depend on those all the time, we&#039;re supposed to be separating markup, style and processing.  Using js or backend processing to make something happen in css is antithetical to this separation.  And as far as harm... you could always choose not to use a variable and roll old-school.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve wanted variables in css for at least 8 years.  Simply put, going from the font tag everywhere to being able to style p&#8217;s was a huge improvement.  I could alter the style for all the p&#8217;s in one place.  But in css itself we still have the &#8216;font tags everywhere&#8217; problem where we&#8217;re trying to implement colors from a style guide.  Say body text, input borders and nav background are #333.  That&#8217;s 3 sets of selectors and rules I have to set up for 1 piece of data.  If the styleguide says those 3 things will always be the same color, even if that color changes, I should be able to set that color in one place.  It sounds as if Bert is coming from more of a CS background than a design background with this argument.  Styleguides have constants.  One of their primary functions is the expression of constants.  And having to hard code values all over the place is a major shortcoming of css as a style language.  Maybe not so big a deal if you&#8217;ve got 30 lines of code in your styles.  But it&#8217;s common for our projects to have 3000 lines of code in styles.  Also, php and javascript aren&#8217;t viable workarounds all the time.  Sometimes you don&#8217;t have javascript available to you.  Sometimes it&#8217;s a flat site and you can&#8217;t have a backend.  And even if you could depend on those all the time, we&#8217;re supposed to be separating markup, style and processing.  Using js or backend processing to make something happen in css is antithetical to this separation.  And as far as harm&#8230; you could always choose not to use a variable and roll old-school.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HudsonTavares</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266507</link>
		<dc:creator>HudsonTavares</dc:creator>
		<pubDate>Thu, 07 Aug 2008 17:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266507</guid>
		<description>Just a correction: On my comment, above, both the &quot;I&#039;m red&quot; and the &quot;Me too&quot; texts are inside of  paragraphs, the first using the classes my-pretty-class and asd, and the second using my-pretty-class and dsa.

Damn XHTML strip.</description>
		<content:encoded><![CDATA[<p>Just a correction: On my comment, above, both the &#8220;I&#8217;m red&#8221; and the &#8220;Me too&#8221; texts are inside of  paragraphs, the first using the classes my-pretty-class and asd, and the second using my-pretty-class and dsa.</p>
<p>Damn XHTML strip.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HudsonTavares</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266506</link>
		<dc:creator>HudsonTavares</dc:creator>
		<pubDate>Thu, 07 Aug 2008 17:35:20 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266506</guid>
		<description>I think that CSS is a good language because of it&#039;s standalone approach. You don&#039;t have includes, import (at least not in the Java way); you don&#039;t have to care if some other file was loaded, if some other part is already defined (except for inheritance purposes), your only effort is totally focused in organization and inheritance of your classes /  ids / other selectors.

IMO, no matter how pretty could be that so-beloved / so-hated CSS &quot;vars&quot;, it would introduce problems more related with programming, rather than styling (like var scope, fallback behavior, undefined vars, etc).

And, also, these vars are a requirement that comes only from a small part (IMO) of web developers / designers / whatever.  You can use, currently - without worrying about when  will incorporate a new CSS capability, things like 


.my-pretty-class{color:red;}
.asd{background-color:white;}
.dsa{background-color:orange;}

I&#039;m red
Me too

If you really need an universal property.</description>
		<content:encoded><![CDATA[<p>I think that CSS is a good language because of it&#8217;s standalone approach. You don&#8217;t have includes, import (at least not in the Java way); you don&#8217;t have to care if some other file was loaded, if some other part is already defined (except for inheritance purposes), your only effort is totally focused in organization and inheritance of your classes /  ids / other selectors.</p>
<p>IMO, no matter how pretty could be that so-beloved / so-hated CSS &#8220;vars&#8221;, it would introduce problems more related with programming, rather than styling (like var scope, fallback behavior, undefined vars, etc).</p>
<p>And, also, these vars are a requirement that comes only from a small part (IMO) of web developers / designers / whatever.  You can use, currently &#8211; without worrying about when  will incorporate a new CSS capability, things like </p>
<p>.my-pretty-class{color:red;}<br />
.asd{background-color:white;}<br />
.dsa{background-color:orange;}</p>
<p>I&#8217;m red<br />
Me too</p>
<p>If you really need an universal property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ialexi</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266501</link>
		<dc:creator>ialexi</dc:creator>
		<pubDate>Thu, 07 Aug 2008 15:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266501</guid>
		<description>@LeoHorie: Re: inheritance: First, proper inheritance is not (from what I&#039;m aware of, at least), possible in CSS. You cannot make one class inherit from a class defined in another file. If you could we could better separate CSS for layout and CSS for styling (which would allow &lt;em&gt;much&lt;/em&gt; smaller CSS style files).

Still, I take back a bit of what I said regarding inheritance earlier. My biggest problem with CSS variables is that they appear to be declared in some sort of global scope, and to me, this seems to be a big no-no. I liked the idea of inheritance because it would allow a much more organized way of storing variables.

An even more organized way, however, could be very simple in concept. Imagine the following code, which illustrates the possibility of inheritance and a better variable scheme (forgive me any errors -- I am a tad rusty at the moment, and also forgive the absolutely terrible color scheme):

&lt;code&gt;
.myColorScheme {
    keyColor: #0000FF;
    accentColor: #FF0000;
}

.boxElement
{
    backgroundColor: myColorScheme.keyColor;
    color: accentColor;
    border: 1px solid myColorScheme.accentColor;
}

/* In another file */
#navigation {
    inherit: boxElement;
    float: left;
    display: block;
    /* Other layout code here */
}
&lt;/code&gt;

This really is not against how CSS is defined; .myClassName selectors aren&#039;t really &lt;em&gt;selectors&lt;/em&gt;, but class definitions. It only makes sense to be able to use the content of those class definitions later.

The inheritance I show would simply insert the properties defined in the class to inherit from into the class inheriting; you could even make one class inherit from another multiple times, but if you did, it would probably mean that you designed your CSS poorly.</description>
		<content:encoded><![CDATA[<p>@LeoHorie: Re: inheritance: First, proper inheritance is not (from what I&#8217;m aware of, at least), possible in CSS. You cannot make one class inherit from a class defined in another file. If you could we could better separate CSS for layout and CSS for styling (which would allow <em>much</em> smaller CSS style files).</p>
<p>Still, I take back a bit of what I said regarding inheritance earlier. My biggest problem with CSS variables is that they appear to be declared in some sort of global scope, and to me, this seems to be a big no-no. I liked the idea of inheritance because it would allow a much more organized way of storing variables.</p>
<p>An even more organized way, however, could be very simple in concept. Imagine the following code, which illustrates the possibility of inheritance and a better variable scheme (forgive me any errors &#8212; I am a tad rusty at the moment, and also forgive the absolutely terrible color scheme):</p>
<p><code><br />
.myColorScheme {<br />
    keyColor: #0000FF;<br />
    accentColor: #FF0000;<br />
}</p>
<p>.boxElement<br />
{<br />
    backgroundColor: myColorScheme.keyColor;<br />
    color: accentColor;<br />
    border: 1px solid myColorScheme.accentColor;<br />
}</p>
<p>/* In another file */<br />
#navigation {<br />
    inherit: boxElement;<br />
    float: left;<br />
    display: block;<br />
    /* Other layout code here */<br />
}<br />
</code></p>
<p>This really is not against how CSS is defined; .myClassName selectors aren&#8217;t really <em>selectors</em>, but class definitions. It only makes sense to be able to use the content of those class definitions later.</p>
<p>The inheritance I show would simply insert the properties defined in the class to inherit from into the class inheriting; you could even make one class inherit from another multiple times, but if you did, it would probably mean that you designed your CSS poorly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JeromeLapointe</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266500</link>
		<dc:creator>JeromeLapointe</dc:creator>
		<pubDate>Thu, 07 Aug 2008 15:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266500</guid>
		<description>We sort of already do have these variables for colors, or maybe they are best described as entities... I can say a color is color:#FFFFFF, but I can just as well say that it&#039;s color:white, color:aqua, color:FireBrick, color:CornflowerBlue.

So why shouldn&#039;t I be able to define these and make up new ones as I define entities in an XML or XSL document? I think newcomers to CSS are able to understand color:white... so why not be able to have color:basetone and color:accents. 

That is what seems to me the most natural direction. Of course it&#039;s very specific to colors... but on the flipside it&#039;s not like there&#039;s a huge demand for variables either and this one would actually have a &quot;type&quot;.

@TNO
I think you mean JSSS...
Doesn&#039;t it lack any control on nodes other than their node names?
It&#039;s extremely laborious to hand code or read because of it&#039;s one line declaration for each node attribute.
Maybe it&#039;s got variables and expressions but without access to Classes and IDs or any other label than the tag names... it won&#039;t be doing anything productive with those variables.

Saying CSS is broken is a pretty bold statement and you don&#039;t say why it is... CSS does what it&#039;s supposed to do and very well.</description>
		<content:encoded><![CDATA[<p>We sort of already do have these variables for colors, or maybe they are best described as entities&#8230; I can say a color is color:#FFFFFF, but I can just as well say that it&#8217;s color:white, color:aqua, color:FireBrick, color:CornflowerBlue.</p>
<p>So why shouldn&#8217;t I be able to define these and make up new ones as I define entities in an XML or XSL document? I think newcomers to CSS are able to understand color:white&#8230; so why not be able to have color:basetone and color:accents. </p>
<p>That is what seems to me the most natural direction. Of course it&#8217;s very specific to colors&#8230; but on the flipside it&#8217;s not like there&#8217;s a huge demand for variables either and this one would actually have a &#8220;type&#8221;.</p>
<p>@TNO<br />
I think you mean JSSS&#8230;<br />
Doesn&#8217;t it lack any control on nodes other than their node names?<br />
It&#8217;s extremely laborious to hand code or read because of it&#8217;s one line declaration for each node attribute.<br />
Maybe it&#8217;s got variables and expressions but without access to Classes and IDs or any other label than the tag names&#8230; it won&#8217;t be doing anything productive with those variables.</p>
<p>Saying CSS is broken is a pretty bold statement and you don&#8217;t say why it is&#8230; CSS does what it&#8217;s supposed to do and very well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: K9</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266499</link>
		<dc:creator>K9</dc:creator>
		<pubDate>Thu, 07 Aug 2008 15:15:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266499</guid>
		<description>I love that variables are too complicated, but the &lt;a href=&quot;http://meyerweb.com/eric/css/inline-format.html&quot; rel=&quot;nofollow&quot;&gt;inline formatting model&lt;/a&gt; is not. JavaScript has been made ten times more useful recently by frameworks, but CSS frameworks will never be really useful until some generality and composability is allowed in CSS. We need basic power in the language, not border-radius or drop shadows.</description>
		<content:encoded><![CDATA[<p>I love that variables are too complicated, but the <a href="http://meyerweb.com/eric/css/inline-format.html" rel="nofollow">inline formatting model</a> is not. JavaScript has been made ten times more useful recently by frameworks, but CSS frameworks will never be really useful until some generality and composability is allowed in CSS. We need basic power in the language, not border-radius or drop shadows.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joeri</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266495</link>
		<dc:creator>Joeri</dc:creator>
		<pubDate>Thu, 07 Aug 2008 14:48:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266495</guid>
		<description>@LeoHorie: 
If caching it on disk was that simple, we would all be doing it. These comments aren&#039;t really the place to go into detail why it&#039;s just not that simple, but well, it&#039;s not that simple.
Your blog post is missing the point of what I (and I suspect others) want these for. I want to do something similar to how the windows color scheme works. You define a small set of a few dozen color variables, and you reuse these throughout all your different controls where they make sense. CSS classes just don&#039;t cut it for this (and believe me, I&#039;ve tried to make them work for me).</description>
		<content:encoded><![CDATA[<p>@LeoHorie:<br />
If caching it on disk was that simple, we would all be doing it. These comments aren&#8217;t really the place to go into detail why it&#8217;s just not that simple, but well, it&#8217;s not that simple.<br />
Your blog post is missing the point of what I (and I suspect others) want these for. I want to do something similar to how the windows color scheme works. You define a small set of a few dozen color variables, and you reuse these throughout all your different controls where they make sense. CSS classes just don&#8217;t cut it for this (and believe me, I&#8217;ve tried to make them work for me).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LeoHorie</title>
		<link>http://ajaxian.com/archives/css-variables-considered-harmful/comment-page-1#comment-266491</link>
		<dc:creator>LeoHorie</dc:creator>
		<pubDate>Thu, 07 Aug 2008 13:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=4032#comment-266491</guid>
		<description>ops, my first paragraph was meant to respond to ialexi, not TNO.</description>
		<content:encoded><![CDATA[<p>ops, my first paragraph was meant to respond to ialexi, not TNO.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

