<?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: Why adding variables to CSS is a good thing</title> <atom:link href="http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/feed/" rel="self" type="application/rss+xml" /><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/</link> <description>You have found Friendly Bit, a web development blog. I focus on client side technologies like CSS, HTML and Javascript. You find my articles below and categories to the right.</description> <lastBuildDate>Wed, 10 Mar 2010 06:46:13 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Variablen in CSS: Werkzeuge und Lösungsansätze &#124; Dr. Web Magazin</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31783</link> <dc:creator>Variablen in CSS: Werkzeuge und Lösungsansätze &#124; Dr. Web Magazin</dc:creator> <pubDate>Tue, 09 Jun 2009 06:11:45 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31783</guid> <description>[...] das Design von Cascading Stylesheets mittels Variablen zu erleichtern und zu beschleunigen. Die Vorteile liegen auf der [...]</description> <content:encoded><![CDATA[<p>[...] das Design von Cascading Stylesheets mittels Variablen zu erleichtern und zu beschleunigen. Die Vorteile liegen auf der [...]</p> ]]></content:encoded> </item> <item><title>By: Shane</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31348</link> <dc:creator>Shane</dc:creator> <pubDate>Sun, 04 Jan 2009 11:17:10 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31348</guid> <description>I think the issue not about using variables, but rather about having the ability to define named constants. The arguments that you make about setting the same margin values over and over again are a cry for named constants. There is a place for these in any language, stylistic (as in css) or otherwise. Given that numeric constants (numbers) were created to replace the more vague concepts of one, a handful, more than handful, many, more than many, etc, the use of named constants to allow for quick and easy manipulation and maintenance of an otherwise complex system just makes sense.</description> <content:encoded><![CDATA[<p>I think the issue not about using variables, but rather about having the ability to define named constants. The arguments that you make about setting the same margin values over and over again are a cry for named constants. There is a place for these in any language, stylistic (as in css) or otherwise. Given that numeric constants (numbers) were created to replace the more vague concepts of one, a handful, more than handful, many, more than many, etc, the use of named constants to allow for quick and easy manipulation and maintenance of an otherwise complex system just makes sense.</p> ]]></content:encoded> </item> <item><title>By: Henrik Lissner</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31248</link> <dc:creator>Henrik Lissner</dc:creator> <pubDate>Wed, 03 Dec 2008 02:35:28 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31248</guid> <description>@Emil: Yes, I did put that into consideration when I first thought it up. What I ended up doing was I set up a private web service, to which the CMS&#039;s I&#039;ve developed POST full stylesheets and receive the rewritten version (subsequently replacing the local stylesheet).The problem comes when someone doesn&#039;t get the CMS, but wants to alter their CSS files, but they usually come back to me in those cases; so I haven&#039;t had to address that need just yet.I suppose I could simply put up a form on my site that could post to that web service. Just some food for thought.Maybe when the project becomes more mature I will make it public.</description> <content:encoded><![CDATA[<p>@Emil: Yes, I did put that into consideration when I first thought it up. What I ended up doing was I set up a private web service, to which the CMS&#8217;s I&#8217;ve developed POST full stylesheets and receive the rewritten version (subsequently replacing the local stylesheet).</p><p>The problem comes when someone doesn&#8217;t get the CMS, but wants to alter their CSS files, but they usually come back to me in those cases; so I haven&#8217;t had to address that need just yet.</p><p>I suppose I could simply put up a form on my site that could post to that web service. Just some food for thought.</p><p>Maybe when the project becomes more mature I will make it public.</p> ]]></content:encoded> </item> <item><title>By: Emil Stenström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31246</link> <dc:creator>Emil Stenström</dc:creator> <pubDate>Tue, 02 Dec 2008 23:27:11 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31246</guid> <description>@Henrik Lissner: That is an interesting idea. The only bad thing about it I can see is that it must be a mess to maintain for people. If you&#039;re using generated code you better give away your generator, and the original file too. Perhaps a website with your generator that people can use? That could in fact be a rather good solution for now.</description> <content:encoded><![CDATA[<p>@Henrik Lissner: That is an interesting idea. The only bad thing about it I can see is that it must be a mess to maintain for people. If you&#8217;re using generated code you better give away your generator, and the original file too. Perhaps a website with your generator that people can use? That could in fact be a rather good solution for now.</p> ]]></content:encoded> </item> <item><title>By: Henrik Lissner</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31244</link> <dc:creator>Henrik Lissner</dc:creator> <pubDate>Tue, 02 Dec 2008 06:52:45 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31244</guid> <description>I do like the idea of CSS constants, but I do sympathize with Bert. However, I don&#039;t agree with the idea of having to develop per-language solutions for a CSS variable alternative.It sounds like you&#039;re saying we should be developing parsers on a per-language basis. But why not make it a pre-deployment step?I have made my own custom solution, a quick &#039;n dirty php script that parses and rewrites my css files en mass. Done locally of course, and the result is uploaded. No need to do any active parsing.Just my 2 cents! Cheers!</description> <content:encoded><![CDATA[<p>I do like the idea of CSS constants, but I do sympathize with Bert. However, I don&#8217;t agree with the idea of having to develop per-language solutions for a CSS variable alternative.</p><p>It sounds like you&#8217;re saying we should be developing parsers on a per-language basis. But why not make it a pre-deployment step?</p><p>I have made my own custom solution, a quick &#8216;n dirty php script that parses and rewrites my css files en mass. Done locally of course, and the result is uploaded. No need to do any active parsing.</p><p>Just my 2 cents! Cheers!</p> ]]></content:encoded> </item> <item><title>By: Emil Stenström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31080</link> <dc:creator>Emil Stenström</dc:creator> <pubDate>Tue, 30 Sep 2008 22:50:01 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31080</guid> <description>@Andreas: Ah, I read CSS-constants. HTML constants is something that I use every day, in different languages. In some they are called includes, in some they are masterpages and contentplaceholder, but they are all the same: Reusable components of HTML.I agree that we use lots of colors in the CSS today. The thing is, many of those can be abstracted away with alphatransparent PNG-images. If we only could get rid of IE6 they would be really usable.Using CSS-constants like Anders suggests would be really useful, I agree!</description> <content:encoded><![CDATA[<p>@Andreas: Ah, I read CSS-constants. HTML constants is something that I use every day, in different languages. In some they are called includes, in some they are masterpages and contentplaceholder, but they are all the same: Reusable components of HTML.</p><p>I agree that we use lots of colors in the CSS today. The thing is, many of those can be abstracted away with alphatransparent PNG-images. If we only could get rid of IE6 they would be really usable.</p><p>Using CSS-constants like Anders suggests would be really useful, I agree!</p> ]]></content:encoded> </item> <item><title>By: Andreas</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31079</link> <dc:creator>Andreas</dc:creator> <pubDate>Mon, 29 Sep 2008 22:27:44 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31079</guid> <description>Thanks for the reply. But you never answered where you would find HTML-constants useful? Surely you don&#039;t specify colours in your markup?Also - if you wanted to change the colour-scheme of a site (at least the ones I normally code) it wouldn&#039;t require the change of one single colour. It would require changes to probably 5-10 different colours _and_ background-images so I&#039;m not sure constants would help that much in that case.I think the biggest benefit of constants is the one that Anders Ytterström mentions, to get rid of _all_ design-related stuff from the HTML. Classes like &quot;box&quot; or &quot;self-clear&quot; or anything that you put in there only because the current design requires it should be in the CSS - not the HTML.</description> <content:encoded><![CDATA[<p>Thanks for the reply. But you never answered where you would find HTML-constants useful? Surely you don&#8217;t specify colours in your markup?</p><p>Also &#8211; if you wanted to change the colour-scheme of a site (at least the ones I normally code) it wouldn&#8217;t require the change of one single colour. It would require changes to probably 5-10 different colours _and_ background-images so I&#8217;m not sure constants would help that much in that case.</p><p>I think the biggest benefit of constants is the one that Anders Ytterström mentions, to get rid of _all_ design-related stuff from the HTML. Classes like &#8220;box&#8221; or &#8220;self-clear&#8221; or anything that you put in there only because the current design requires it should be in the CSS &#8211; not the HTML.</p> ]]></content:encoded> </item> <item><title>By: Emil Stenström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31077</link> <dc:creator>Emil Stenström</dc:creator> <pubDate>Mon, 29 Sep 2008 16:57:19 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31077</guid> <description>@Andreas: Yes, constants is a better name, I just picked the name used in the references file.Coloring is a perfect place where constants would be useful. If the client changes their mind concerning a color you just change that constant. No need for search/replace. And no need to write a Java-CSS wrapper...</description> <content:encoded><![CDATA[<p>@Andreas: Yes, constants is a better name, I just picked the name used in the references file.</p><p>Coloring is a perfect place where constants would be useful. If the client changes their mind concerning a color you just change that constant. No need for search/replace. And no need to write a Java-CSS wrapper&#8230;</p> ]]></content:encoded> </item> <item><title>By: Andreas</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-31075</link> <dc:creator>Andreas</dc:creator> <pubDate>Sun, 28 Sep 2008 23:18:32 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-31075</guid> <description>I&#039;ve always been a fan of CSS-constants (they are constants are they not? They never change during run-time right?) but I&#039;m not so sure they should be in there by default.They&#039;re silly-easy to implement using _any_ server-side-language and the syntax in the CSS wouldn&#039;t have to change from server-side-language to language at all so you could re-use your CSS from server to server without problem.@Anders Ytterström - I like how you think and I had exactly the same ideas as you when I built my &lt;a href=&quot;http://exscale.se/archives/2008/01/15/css-constants-and-compression-php-class/&quot; rel=&quot;nofollow&quot;&gt;CSS constants PHP Class&lt;/a&gt;. To remove the need for classes altogether.I&#039;m curious to know where you think HTML-constants (or variables) would be useful?</description> <content:encoded><![CDATA[<p>I&#8217;ve always been a fan of CSS-constants (they are constants are they not? They never change during run-time right?) but I&#8217;m not so sure they should be in there by default.</p><p>They&#8217;re silly-easy to implement using _any_ server-side-language and the syntax in the CSS wouldn&#8217;t have to change from server-side-language to language at all so you could re-use your CSS from server to server without problem.</p><p>@Anders Ytterström &#8211; I like how you think and I had exactly the same ideas as you when I built my <a
href="http://exscale.se/archives/2008/01/15/css-constants-and-compression-php-class/">CSS constants PHP Class</a>. To remove the need for classes altogether.</p><p>I&#8217;m curious to know where you think HTML-constants (or variables) would be useful?</p> ]]></content:encoded> </item> <item><title>By: Anders Ytterström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30924</link> <dc:creator>Anders Ytterström</dc:creator> <pubDate>Sat, 16 Aug 2008 11:23:28 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30924</guid> <description>I can see the benefit. Adding variables on the presentation level should give one the opportunity to stop using &quot;variables&quot; on the content level.With that, I mean the use of mutliple common classes to create a presentation of a block:
&lt;code&gt;&lt;div class=&quot;nav horisontal tabbed&quot;&gt;...&gt;&lt;/code&gt;It would be nice to instead create the css-variables nav, horisontal and tabbed in the css file(s) and use them internal. Would spare some non-content markup in the HTML.Is this a good reason, Emil, or have did I miss the whole real part of CSS variables?</description> <content:encoded><![CDATA[<p>I can see the benefit. Adding variables on the presentation level should give one the opportunity to stop using &#8220;variables&#8221; on the content level.</p><p>With that, I mean the use of mutliple common classes to create a presentation of a block:<br
/> <code>&lt;div class="nav horisontal tabbed"&gt;...&gt;</code></p><p>It would be nice to instead create the css-variables nav, horisontal and tabbed in the css file(s) and use them internal. Would spare some non-content markup in the HTML.</p><p>Is this a good reason, Emil, or have did I miss the whole real part of CSS variables?</p> ]]></content:encoded> </item> <item><title>By: Emil Stenström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30914</link> <dc:creator>Emil Stenström</dc:creator> <pubDate>Tue, 12 Aug 2008 18:16:13 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30914</guid> <description>@Rasmus Kaj: Yes, I mean symbolic constants. They are called CSS Variables in the &lt;a href=&quot;http://disruptive-innovations.com/zoo/cssvariables/&quot; rel=&quot;nofollow&quot;&gt;proposed spec&lt;/a&gt;, that&#039;s why I used that.Do you mean HTML character entities? Or are there some other kind of entity that I don&#039;t know about? Another type of symbolic constant is the use of frames. It lets you divide your page into different parts and reuse them (Aside: &lt;a href=&quot;http://www.w3.org/TR/WD-wwwicn.html&quot; rel=&quot;nofollow&quot;&gt;Fun spec&lt;/a&gt;, found while googling).Preprocessing can solve these issues, but if preprocessing is something you always want, no matter what language, why not work at including it in the spec?</description> <content:encoded><![CDATA[<p>@Rasmus Kaj: Yes, I mean symbolic constants. They are called CSS Variables in the <a
href="http://disruptive-innovations.com/zoo/cssvariables/">proposed spec</a>, that&#8217;s why I used that.</p><p>Do you mean HTML character entities? Or are there some other kind of entity that I don&#8217;t know about? Another type of symbolic constant is the use of frames. It lets you divide your page into different parts and reuse them (Aside: <a
href="http://www.w3.org/TR/WD-wwwicn.html">Fun spec</a>, found while googling).</p><p>Preprocessing can solve these issues, but if preprocessing is something you always want, no matter what language, why not work at including it in the spec?</p> ]]></content:encoded> </item> <item><title>By: Rasmus Kaj</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30913</link> <dc:creator>Rasmus Kaj</dc:creator> <pubDate>Tue, 12 Aug 2008 10:55:47 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30913</guid> <description>When you say variables, I hope you mean symbolic constants?  In that case, I agree that they might be useful.  The semantics of such constants (regarding e.g. @include rules) might be complex enough, without considering changing values as well.And by the way, HTML already has such symbolic constants, they&#039;re called entities.  They can only be declared in the DOCTYPE, not in the page content, but they can still be usefull.  Last time I used them, I made sure to evaluate them in a preprocessing step, though.  Not in the browser.And preprosessing can be useful for css as well.  Plain old cpp or m4 is actually very useful, both for symbolic constants and for merging separate files to a single &quot;end-user&quot; file.</description> <content:encoded><![CDATA[<p>When you say variables, I hope you mean symbolic constants?  In that case, I agree that they might be useful.  The semantics of such constants (regarding e.g. @include rules) might be complex enough, without considering changing values as well.</p><p>And by the way, HTML already has such symbolic constants, they&#8217;re called entities.  They can only be declared in the DOCTYPE, not in the page content, but they can still be usefull.  Last time I used them, I made sure to evaluate them in a preprocessing step, though.  Not in the browser.</p><p>And preprosessing can be useful for css as well.  Plain old cpp or m4 is actually very useful, both for symbolic constants and for merging separate files to a single &#8220;end-user&#8221; file.</p> ]]></content:encoded> </item> <item><title>By: Emil Stenström</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30909</link> <dc:creator>Emil Stenström</dc:creator> <pubDate>Mon, 11 Aug 2008 19:49:06 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30909</guid> <description>@Jonah Dempcy: Sorry, wordpress destroyed your code, I couldn&#039;t restore it by guessing :( I see what you mean though. I tend to have one file for IE hacks, and one for all other browsers. Then again, I only support IE6 and IE7.</description> <content:encoded><![CDATA[<p>@Jonah Dempcy: Sorry, wordpress destroyed your code, I couldn&#8217;t restore it by guessing :( I see what you mean though. I tend to have one file for IE hacks, and one for all other browsers. Then again, I only support IE6 and IE7.</p> ]]></content:encoded> </item> <item><title>By: Jonah Dempcy</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30907</link> <dc:creator>Jonah Dempcy</dc:creator> <pubDate>Sun, 10 Aug 2008 21:29:41 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30907</guid> <description>@Andreas: For performance reasons, you will ideally want to serve only one CSS file per page. If you want to separate the CSS file into multiple separate files, then you should write a build script that combines them all into a single file when deployed to the production website. You can still keep separate files for local development, if you like.Personally, I prefer one file since I usually use inline find (CTRL+J) in Aptana to locate a given section of code. For those unfamiliar with inline find, it works the same as normal find but doesn&#039;t cause a window to popup, so you can just start typing at any time. Firefox includes this as the default find behavior (when clicking CTRL+F).On a side not, I abhor including separate IE stylesheets. It&#039;s become commonplace now for sites to use conditional comments to include separate IE stylesheets, for instance:&lt;code&gt;
&lt;!--[if lte IE 5.5] --&gt;
&lt;!--[if IE 6]--&gt;
&lt;!--[if gte IE 7]--&gt;
&lt;/code&gt;This method frustrates me because I need to open 4 separate stylesheets to see all of the rules that are affecting an element. Instead, I much prefer this:&lt;code&gt;
&lt;!--[if lte IE 5.5]--&gt;
&lt;!--[if IE 6]--&gt;
&lt;!--[if gte IE 7]--&gt;
&lt;!--[if !IE]--&gt;
&lt;/code&gt;
This allows me to write CSS rules all in the same stylesheet, like so:&lt;code&gt;
#some-element {
color: red;
}
.ie #some-element {
color: blue;
}
.ie6 #some-element {
padding-top: 10px;
}
.ie7 #some-element {
line-height: 120%;
}
&lt;/code&gt;</description> <content:encoded><![CDATA[<p>@Andreas: For performance reasons, you will ideally want to serve only one CSS file per page. If you want to separate the CSS file into multiple separate files, then you should write a build script that combines them all into a single file when deployed to the production website. You can still keep separate files for local development, if you like.</p><p>Personally, I prefer one file since I usually use inline find (CTRL+J) in Aptana to locate a given section of code. For those unfamiliar with inline find, it works the same as normal find but doesn&#8217;t cause a window to popup, so you can just start typing at any time. Firefox includes this as the default find behavior (when clicking CTRL+F).</p><p>On a side not, I abhor including separate IE stylesheets. It&#8217;s become commonplace now for sites to use conditional comments to include separate IE stylesheets, for instance:</p><p><code><br
/> &lt;!--[if lte IE 5.5] --&gt;<br
/> &lt;!--[if IE 6]--&gt;<br
/> &lt;!--[if gte IE 7]--&gt;<br
/> </code></p><p>This method frustrates me because I need to open 4 separate stylesheets to see all of the rules that are affecting an element. Instead, I much prefer this:</p><p><code><br
/> &lt;!--[if lte IE 5.5]--&gt;<br
/> &lt;!--[if IE 6]--&gt;<br
/> &lt;!--[if gte IE 7]--&gt;<br
/> &lt;!--[if !IE]--&gt;<br
/> </code><br
/> This allows me to write CSS rules all in the same stylesheet, like so:</p><p><code><br
/> #some-element {<br
/> color: red;<br
/> }<br
/> .ie #some-element {<br
/> color: blue;<br
/> }<br
/> .ie6 #some-element {<br
/> padding-top: 10px;<br
/> }<br
/> .ie7 #some-element {<br
/> line-height: 120%;<br
/> }<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Prom?nné v CSS. A není to chyba? - Martin Hassman: blog nejen o prohlíže?ích</title><link>http://friendlybit.com/css/why-adding-variables-to-css-is-a-good-thing/#comment-30900</link> <dc:creator>Prom?nné v CSS. A není to chyba? - Martin Hassman: blog nejen o prohlíže?ích</dc:creator> <pubDate>Sun, 10 Aug 2008 12:26:24 +0000</pubDate> <guid
isPermaLink="false">http://friendlybit.com/?p=171#comment-30900</guid> <description>[...] už to na internetu chodí, netrvalo dlouho, aby se objevili reakce, odkažme alespo? Why adding variables to  CSS is a good thing a Why CSS Variables are harmful : the pragmatic [...]</description> <content:encoded><![CDATA[<p>[...] už to na internetu chodí, netrvalo dlouho, aby se objevili reakce, odkažme alespo? Why adding variables to  CSS is a good thing a Why CSS Variables are harmful : the pragmatic [...]</p> ]]></content:encoded> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 24/36 queries in 0.039 seconds using disk

Served from: c8.67.364a.static.theplanet.com @ 2010-03-10 13:30:21 -->