<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title></title>
	<atom:link href="http://www.dannychambers.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dannychambers.co.uk</link>
	<description></description>
	<lastBuildDate>Wed, 12 Sep 2012 08:53:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Precisely defining your fluid grid</title>
		<link>http://www.dannychambers.co.uk/2012/precisely-defining-your-fluid-grid/</link>
		<comments>http://www.dannychambers.co.uk/2012/precisely-defining-your-fluid-grid/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 15:05:50 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dannychambers.co.uk/?p=250</guid>
		<description><![CDATA[A note on turning pixels into percentages]]></description>
			<content:encoded><![CDATA[<p class="opening">Ethan Marcotte in his excellent book <a href="http://www.abookapart.com/products/responsive-web-design">Responsive Web Design</a> gives us a formula for defining our layouts in percentages derived from a pixel perfect design. The formula, is target width divided by context width (<code>target / context = %</code>). However, in chapter 2 when choosing his overall grid with, Ethan says:</p>
<blockquote>
<p>I&#8217;ll confess that I arrived at 90% somewhat arbitrarily, doing a bit of trial and error in the browser window to see what looked best.</p>
</blockquote>
<p>I&#8217;m not sure why Ethan chose not to use his formula here, if we do, we find that the 960px he needs works out to be 93.7% of 1024 pixels, whereas 90% would translate to a screen width of around 1066 pixels. If we are going to use his method accurately we need to use it from the outset otherwise our grid is wrong right from the beginning.</p>
<h2>Allow Scrollbars</h2>
<p>Another thing to consider is the vertical scrollbar. When clicking through from a shorter page to a longer one, the apperance of a scrollbar can cause a &#8216;jump&#8217; in a sites central alignment which is quite undesirable. The generally accepted solution to this is to force the vertical scrollbar using an attribute of <code>overflow-y: scroll;</code> on the body element. However if we do that, we need to incorporate the reduction in page width of 17px to the formula so that we aren&#8217;t miscalculating our new &#8216;precise&#8217; grid width. So we now have:</p>
<p><code>target / (context - 17px) = %</code> When forcing a vertical scrollbar.</p>
<p>I&#8217;m keen to here if others have approached this problem, or can otherwise explain the reasoning behind the arbitrary 90% in the book.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dannychambers.co.uk/2012/precisely-defining-your-fluid-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to mark up your forms using only HTML form elements</title>
		<link>http://www.dannychambers.co.uk/2012/how-to-mark-up-your-forms-using-only-html-form-elements/</link>
		<comments>http://www.dannychambers.co.uk/2012/how-to-mark-up-your-forms-using-only-html-form-elements/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 13:14:51 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dannychambers.co.uk/?p=148</guid>
		<description><![CDATA[If you're a bit of an HTML purist, you might have asked yourself "Is it a good idea to use an ordered list to mark up my web forms?" or "Do I really need to use all of these semantically weak <code>&#60;div&#62;</code> tags just to give my form a bit of presentational structure?"]]></description>
			<content:encoded><![CDATA[<p class="opening">If you&#8217;re a bit of an HTML purist, you might have asked yourself &#8220;Is it a good idea to use an ordered list to mark up my web forms?&#8221; or &#8220;Do I really need to use all of these semantically weak <code>&lt;div&gt;</code> tags just to give my form a bit of presentational structure?&#8221;. Let&#8217;s take a look at two popular methods used to structure forms and then look at a slimmer alternative..</p>
<h2>Method one: The ordered list</h2>
<p>The example mark up below uses an ordered list to give our form structure, we can use the <code>&lt;li&gt;</code> elements as rows to contain our <code>&lt;label&gt;</code> and <code>&lt;input&gt;</code> tags which we can then float or manipulate easily as blocks.</p>
<pre><code>&lt;ol&gt;
  &lt;li&gt;
     &lt;label for="fldFirstName"&gt;First Name&lt;/label&gt;
     &lt;input type="text" name="fldFirstName" id="fldFirstName" /&gt;
  &lt;/li&gt;
  &lt;li&gt;
     &lt;label for="fldSecondName"&gt;Second Name&lt;/label&gt;
     &lt;input type="text" name="fldSecondName" id="fldSecondName" /&gt;
  &lt;/li&gt;
&lt;/ol&gt;</code></pre>
<p>The good thing about putting a form in an ordered list apart from it&#8217;s structural benefit is that a screen reader will declare the length of the list before reading it, giving the user some extra information about what they have ahead of them.</p>
<h2>Method two: divs divs divs</h2>
<p>Using the <code>&lt;div&gt;</code> element as a form row also gives us structure to play with and there&#8217;s more flexibility than with a list because there aren&#8217;t any rules about how we nest them. It could be argued however, that they are less meaningful.</p>
<pre><code>&lt;div&gt;
  &lt;label for="fldFirstName"&gt;First Name&lt;/label&gt;
  &lt;input type="text" name="fldFirstName" id="fldFirstName" /&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;label for="fldSecondName"&gt;Second Name&lt;/label&gt;
  &lt;input type="text" name="fldSecondName" id="fldSecondName" /&gt;
&lt;/div&gt;</code></pre>
<h2>So what can I do using only HTML form elements?</h2>
<p>In the following example our form is built using only form elements provided to us in HTML, each &#8216;row&#8217; of our form is in fact our <code>&lt;label&gt;</code> element and inside it is our <code>&lt;input&gt;</code> element. Placing the input element inside of the label creates an implicit relationship between the pair, so no <code>for</code> or <code>id</code> attributes are required.</p>
<pre><code>&lt;label data-labelText="First Name"&gt;
  First Name
  &lt;input type="text" name="fldFirstName" /&gt;
&lt;/label&gt;
&lt;label data-labelText="Last Name"&gt;
  Last Name
  &lt;input type="text" name="fldLastName" /&gt;
&lt;/label&gt;</code></pre>
<p>In order to make this mark up present as we want it to, we need each part of it to behave like a styleable element. Our <code>label</code> (or &#8216;form row&#8217;) and <code>input</code> elements are no problem to style, but what about the label text itself.. how can we treat a text node like a block level element? We achieve this by using the <code>:before</code> pseudo class.</p>
<p>In the CSS below we start by hiding the label&#8217;s text using a combination of negative <code>letter-spacing</code> and negative <code>text-indent</code>. We use both of these styles to cover browser variations. The next step is to re-inject our label text using the <code>:before</code> pseudo class with a reference to the <code>data-labelText</code> via the attr selector, we are now able to treat the generated content like a block level element without using any extra structural mark up.</p>
<pre><code>label {
  overflow: hidden
  display: block;
  margin-bottom: 15px;
  letter-spacing: -9999px;
  text-indent: -9999px;
}

label input {
  float: left;
  width: 70%;
  padding: 3px;
  letter-spacing: normal;
  position: relative;
}

label:before {
  display: block;
  float: left;
  width: 30%;
  padding-right: 10px;
  letter-spacing: normal;
  text-indent: 0;
  text-align: right;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  content: attr(data-labelText);
}</code></pre>
<p>Here is a <a href="http://example.dannychambers.co.uk/lean-forms.html">working example</a> of a form using this &#8216;lean forms&#8217; method. You may notice in the examples that I am mixing percentage widths with pixel paddings, I&#8217;m able to do this by using the <code>box-sizing: border-box</code> method explained <a href="http://paulirish.com/2012/box-sizing-border-box-ftw/">here</a>.</p>
<h3>Support</h3>
<ul class="support">
<li id="ie"><a href="#none" title="Internet Explorer 8+">Internet Explorer 8+</a></li>
<li id="opera"><a href="#none" title="Opera">Opera</a></li>
<li id="safari"><a href="#none" title="Safari">Safari</a></li>
<li id="firefox"><a href="#none" title="Firefox">Firefox</a></li>
<li id="chrome"><a href="#none" title="Chrome">Chrome</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dannychambers.co.uk/2012/how-to-mark-up-your-forms-using-only-html-form-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Floating lists into columns without using class=&quot;last&quot;</title>
		<link>http://www.dannychambers.co.uk/2012/floating-lists-into-columns-without-using-classlast/</link>
		<comments>http://www.dannychambers.co.uk/2012/floating-lists-into-columns-without-using-classlast/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 12:55:44 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dannychambers.co.uk/?p=18</guid>
		<description><![CDATA[When making a gallery of images or a grid of spotlights on a webpage the preferable option for mark-up is to use an unordered list. Each list item is floated to the left and given a right and bottom margin and, assuming you are working with a fixed width layout..]]></description>
			<content:encoded><![CDATA[<p class="opening">When making a gallery of images or a grid of spotlights on a webpage the preferable option for mark-up is to use an unordered list. Each list item is floated to the left and given a right and bottom margin and, assuming you are working with a fixed width layout you can define the width of each list item so that everything arranges itself nicely within the grid, that is of course.. once you have found a way to remove that pesky right hand margin from every list item on the end of each row.</p>
<p><code>
<pre>ul.grid {
        overflow: hidden;
	list-style: none;
}

ul.grid li {
	float: left;
	width: 250px;
	margin: 0  15px 15px 0;
}</pre>
<p></code></p>
<p><a href="http://www.dannychambers.co.uk/wp-content/uploads/2012/01/broken-grid.jpg"><img src="http://www.dannychambers.co.uk/wp-content/uploads/2012/01/broken-grid.jpg" alt="Broken float" title="Broken float" class="aligncenter size-full wp-image-71" /></a></p>
<p>In the example above we need to remove the right hand margin from every third list item.</p>
<h2>A not so uncommon solution</h2>
<p>It&#8217;s not that uncommon to see this problem solved by the addition of a class to every third child of our list: <code>&lt;li class="last"&gt;</code>. I have done this in the past and had complaints from back-end developers when it comes to integration with a CMS, for whatever reason it&#8217;s a pain in the arse, and a better solution is required.</p>
<h2>A future solution</h2>
<p>CSS3 offers a neat pseudo selector called <code>nth-child</code> which can target child elements based on index. The following code removes the right hand margin from every third list item. </p>
<p><code>
<pre>ul.grid li:nth-child(3n+3) {
  margin-right: 0;
}</pre>
<p></code></p>
<p>Unfortunately <code>nth-child</code> is not supported by by IE before version 9, so is not yet an option.</p>
<h2>A simple, widely supported answer</h2>
<p>In the following example the problem is solved by adding a negative right hand margin to the <code>&lt;ul&gt;</code> element. This does require that the parent element of your grid has the property of <code>overflow:hidden;</code>, if that&#8217;s not possible in your design, you can add a wrapper around your <code>&lt;ul&gt;&lt;/ul&gt;</code> with the overflow hidden property.</p>
<p><code>
<pre>ul.grid {
	margin-right: -15px;
        overflow: hidden;
	list-style: none;
}

ul.grid li {
	float: left;
	width: 250px;
	margin: 0  15px 15px 0;
}</pre>
<p></code></p>
<p><a href="http://www.dannychambers.co.uk/wp-content/uploads/2012/01/fixed-grid.jpg"><img src="http://www.dannychambers.co.uk/wp-content/uploads/2012/01/fixed-grid.jpg" alt="Fixed float" title="Fixed float" class="aligncenter size-full wp-image-74" /></a></p>
<p>Here is the <a href="http://example.dannychambers.co.uk/floating-lists-into-columns-without-using-class-last.html">Working example</a>.</p>
<h3>Support</h3>
<ul class="support">
<li id="ie"><a href="#none" title="Internet Explorer 7 / 8 / 9">Internet Explorer 7 / 8 / 9</a></li>
<li id="opera"><a href="#none" title="Opera">Opera</a></li>
<li id="safari"><a href="#none" title="Safari">Safari</a></li>
<li id="firefox"><a href="#none" title="Firefox">Firefox</a></li>
<li id="chrome"><a href="#none" title="Chrome">Chrome</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dannychambers.co.uk/2012/floating-lists-into-columns-without-using-classlast/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
