<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Tag CSS</title>
    <link>http://blog.kineticweb.com/articles/tag/css</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>CSS/XHTML vs. tables and crap</title>
      <description>&lt;p&gt;While beginning a new project today, I quickly discovered that the &lt;span class="caps"&gt;HTML&lt;/span&gt; and &lt;span class="caps"&gt;CSS&lt;/span&gt; files supplied by the designer were clearly auto-generated from a program like Dreamweaver.&lt;/p&gt;


	&lt;p&gt;It soon became apparent that dealing with nearly half a dozen nested tables and a mess of a &lt;span class="caps"&gt;CSS&lt;/span&gt; (with some of the same font declarations repeated 10 times) was going to be a nightmare.&lt;/p&gt;


	&lt;p&gt;I undertook the task of rebuiding in &lt;em&gt;real&lt;/em&gt; CSS with semantic markup and &lt;span class="caps"&gt;XHTML&lt;/span&gt;. It&amp;#8217;s taken about 3 hours for the rough cut. I still have some tweaking for IE and such but basically, it&amp;#8217;s done. It&amp;#8217;s clearly, far easier to read now. But I&amp;#8217;ll let the numbers speak for themselves:&lt;/p&gt;


Before:
	&lt;ul&gt;
	&lt;li&gt;371 lines&lt;/li&gt;
		&lt;li&gt;13,213 chrs&lt;/li&gt;
	&lt;/ul&gt;


After: 
	&lt;ul&gt;
	&lt;li&gt;279 lines&lt;/li&gt;
		&lt;li&gt;7,173 chrs&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;That&amp;#8217;s nearly a 45% reduction in the number of characters. One place in particular went from looking like this in the Firebug Inspect window:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt; div &amp;lt; td &amp;lt; tr &amp;lt; tbody &amp;lt; table &amp;lt; td &amp;lt; tr &amp;lt; tbody &amp;lt; table &amp;lt; div &amp;lt;
td &amp;lt; tr &amp;lt; tbody &amp;lt; td &amp;lt; tr &amp;lt; tbody &amp;lt; table &amp;lt; td &amp;lt; tr &amp;lt; table &amp;lt; body &amp;lt; html &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

To this:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt; div &amp;lt; div &amp;lt; body &amp;lt; html &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Tue, 23 Oct 2007 21:35:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:f8012f88-a242-4d6b-a958-d200b72e291d</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/10/23/css-xhtml-vs-tables-and-crap</link>
      <category>CSS</category>
      <category>xhtml</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/68</trackback:ping>
    </item>
    <item>
      <title>CSS attribute selectors</title>
      <description>&lt;p&gt;Every single day I learn some new &lt;span class="caps"&gt;CSS&lt;/span&gt; tidbit I didn&amp;#8217;t know. Never before did I realize that there was an &lt;strong&gt;attribute&lt;/strong&gt; selector for &lt;span class="caps"&gt;CSS&lt;/span&gt;!&lt;/p&gt;


	&lt;p&gt;As I was working on the stylesheet for our latest project, &lt;a href="http://www.waycoolmail.com"&gt;Way Cool Mail&lt;/a&gt;, I realized I wanted a slightly different style on buttons then I did on text input fields. So I made a class for the buttons and applied it every where I used a button. (I thought about overriding Rails button helper to always use that class. But that seemed dirty.)&lt;/p&gt;


	&lt;p&gt;Now I discovered via &lt;a href="http://www.amazon.com/CSS-Mastery-Advanced-Standards-Solutions/dp/1590596145"&gt;&lt;span class="caps"&gt;CSS&lt;/span&gt; Mastery: Advanced Web Standards Solutions&lt;/a&gt; that one can do something like this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;input[type=&amp;quot;submit&amp;quot;] {
  border: 1px solid #000
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Of course, it doesn&amp;#8217;t work in &lt;span class="caps"&gt;IE6&lt;/span&gt; and below. (ARGH!!!). So I&amp;#8217;ll either have to keep the separate class or try &lt;a href="http://www.shayna.com/index.cfm?fuseaction=blog.display_entry&amp;#38;id=176"&gt;this handy JS trick&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 02 Aug 2007 07:21:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:555a8a87-eed7-4e85-b145-d3588f4c7936</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/08/02/css-attribute-selectors</link>
      <category>CSS</category>
      <category>Rails</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/50</trackback:ping>
    </item>
    <item>
      <title>CSS with ERB</title>
      <description>&lt;p&gt;As I started to get deeper into creating the stylesheet for our latest project, I got annoyed with having to repeat the same color hex codes all over the place. There are many solutions to this dilemma but I liked &lt;a href="http://blog.hasmanythrough.com/2006/03/23/dirt-simple-rcss-templates"&gt;this one&lt;/a&gt; the best. (Note the blog name is a coincidence.)&lt;/p&gt;


	&lt;p&gt;I had to modify the suggested route slightly as this article is fairly outdated and doesn&amp;#8217;t work with the latest rails version that considers dot a separator in routes. So I used this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;map&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;connect&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;stylesheets/:rcss.:format&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;stylesheets&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rcss&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;So far this is working great. I have several color codes setup as instance variables in the controller. Andy suggested I try moving this to perhaps a layout for the css. If the list of variables gets unwieldy I&amp;#8217;ll do just that.&lt;/p&gt;


	&lt;p&gt;Speaking of color hex codes, &lt;a href="http://flickr.com/photos/jeremyjohnson/847449633/"&gt;this car license plate&lt;/a&gt; is pretty funny.&lt;/p&gt;</description>
      <pubDate>Sat, 21 Jul 2007 17:17:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:a0e5cd37-55be-42b5-82a4-99248935e846</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/07/21/css-with-erb</link>
      <category>CSS</category>
      <category>Rails</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/47</trackback:ping>
    </item>
    <item>
      <title>These are a few of my favorite HTML tags...</title>
      <description>&lt;p&gt;When we began the switch to rails about 6 months ago, I also started to push a transition to &lt;span class="caps"&gt;CSS&lt;/span&gt;-based designs and away from tables based layouts. I saw great value in using more semantic &lt;span class="caps"&gt;HTML&lt;/span&gt; which wrote cleaner code and also provided a separation between display formatting and actual content.&lt;/p&gt;


	&lt;p&gt;This transition has opened me up to a bunch of &lt;span class="caps"&gt;HTML&lt;/span&gt; tags that I rarely used before, or even new existed. And so, I present, my favorite &lt;span class="caps"&gt;HTML&lt;/span&gt; tags:&lt;/p&gt;


&lt;dl&gt;
  &lt;dt&gt;&lt;code&gt;dl dt dd&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Definition List, Data, and Term are really handy when you have a list of items you need to describe. The default style on most browsers bolds the Term and indents the Data underneath it Which is okay but can be easily overwritten with &lt;span class="caps"&gt;CSS&lt;/span&gt;.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;h1&lt;/code&gt;..&lt;code&gt;h6&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;I remember using these way back in &lt;span class="caps"&gt;HTML 1&lt;/span&gt;.0 but somehow I stopped and ended up with &lt;code&gt;&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;Headline&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;/code&gt;. I can&amp;#8217;t understate the usefulness of headline tags.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;ul&lt;/code&gt; and &lt;code&gt;li&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;The power of Unordered Lists is just incredible when you realize how they can be styled in such diverse ways with &lt;span class="caps"&gt;CSS&lt;/span&gt;. Whenever I find myself with a list items (often links) I use &lt;code&gt;ul&lt;/code&gt;.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;label&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;I always used to put a bunch of fields in a form in a big table with two columns. But with &lt;code&gt;label&lt;/code&gt; tags, one can simply style the labels to have a fixed width and you get the same effective. A lot less markup.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;optgroup&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Another one I didn&amp;#8217;t even know existed. Admitedly, it&amp;#8217;s an &lt;span class="caps"&gt;HTML 4&lt;/span&gt; tag. But I often have drop down boxes where groupings within them would be nice. And previously, I would have had to use some kind of Javascript or server side validation to forbid slection of those grouping headings. With &lt;code&gt;optgroup&lt;/code&gt;, browsers don&amp;#8217;t allow you to select the grouping itself.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;fieldset&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;Fieldset is a perfect semantic method of grouping elements within a form together. The default styles in most browsers create a nice little box around your fields with the name of the section (ie: &amp;#8220;Billing Address&amp;#8221;) at the top.&lt;/dd&gt;

  &lt;dt&gt;&lt;code&gt;th&lt;/code&gt;&lt;/dt&gt;
  &lt;dd&gt;I didn&amp;#8217;t even know Table Header tags existed until a few months ago. It makes it much cleaner to style the headings above columns. No more &lt;code&gt;&amp;lt;b&amp;gt;&lt;/code&gt; tags in every single field!&lt;/dd&gt;
&lt;/dl&gt;

	&lt;p&gt;And now, let&amp;#8217;s please pause for a moment of silence for the &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt; tag (Previously known as &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;.), who recently left this world. I&amp;#8217;ve all but stopped using the the Break tag, except when it actually makes sense: intentional line breaks within paragraphs of text. No more &lt;code&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/code&gt; to space something down a page. And never again will I do the old &lt;code&gt;&amp;lt;font size="1"&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/font&amp;gt;&lt;/code&gt; to space something down just a tiny bit.&lt;/p&gt;</description>
      <pubDate>Sat, 12 May 2007 09:49:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:46d3d0e1-ada9-4be1-b94c-bf4b4f69f104</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/12/these-are-a-few-of-my-favorite-html-tags</link>
      <category>HTML</category>
      <category>CSS</category>
    </item>
  </channel>
</rss>
