<?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>Web Designer Notebook &#187; CSS</title>
	<atom:link href="http://webdesignernotebook.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdesignernotebook.com</link>
	<description>Web Designer Notebook is a blog for web designers featuring topics like CSS, HTML and Wordpress, tutorials, reviews and inspiration.</description>
	<lastBuildDate>Sun, 22 Jan 2012 14:07:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>The Wonderful calc() Function</title>
		<link>http://webdesignernotebook.com/css/the-wonderful-calc-function/</link>
		<comments>http://webdesignernotebook.com/css/the-wonderful-calc-function/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 22:36:28 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1411</guid>
		<description><![CDATA[Sitting right at the top of my CSS wishlist was always the implementation of the calc() function. With it now being supported by not only Firefox 4 but Internet Explorer 9, I think it’s time for a quick overview on how useful calc() can be and why it would be great to see more usage [...]]]></description>
			<content:encoded><![CDATA[<p>Sitting right at the top of <a href="http://24ways.org/2010/my-css-wish-list" rel="nofollow" >my CSS wishlist</a> was always the implementation of the <code>calc()</code> function. With it now being supported by not only Firefox 4 but Internet Explorer 9, I think it’s time for a quick overview on how useful <code>calc()</code> can be and why it would be great to see more usage of it.</p>
<p><span id="more-1411"></span></p>
<h3>What is calc()?</h3>
<p>The <code>calc()</code> function can be used to specify lengths. For example, you can use it for values of borders, margins, paddings, fonts, etc. Calculating widths can be extremely complicated, especially in fluid layouts; <code>calc()</code> is unique because it lets you make these calculations within the CSS itself.</p>
<p>It accepts addition (“<code>+</code>”), subtraction (“<code>-</code>“), multiplication (“<code>*</code>”) and division (“<code>/</code>“).</p>
<p>Let’s look at a simple example: </p>
<pre class="brush: css; title: ; notranslate">div {
	width: calc(100% - 20px); }</pre>
<p>Easy, right? You can also have more than one calculation within a single function, for example:</p>
<pre class="brush: css; title: ; notranslate">div {
	width: calc(100% - 20px + 2px*2); }</pre>
<p>In the current specification, it is stated that multiplication and division expressions have precedence over addition and subtraction. This means that, in the previous example, “<code>2px*2</code>” will be calculated before the other two expressions. Also, note that divisions by zero will (or should) result in an error.</p>
<p>The spec is not yet finalised (there is an <a href="http://dev.w3.org/csswg/css3-values/" rel="nofollow" >Editor’s Draft version</a> that expands on the <a href="http://www.w3.org/TR/css3-values/" rel="nofollow" >CSS3 Values and Units Working Draft version</a>), but these are the basics. </p>
<h3>A simple use case</h3>
<p>To show calc’s usefulness further, <a href="http://webdesignernotebook.com/examples/calc-function.html" rel="nofollow" >I’ve created a basic layout</a> where I’ve applied it generously.</p>
<p>The layout consists of a main content container on the left, a sidebar on the right, and a footer, below the previous two. Here is the basic markup with only part of the text being shown, for brevity:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div class=&quot;wrapper&quot;&gt;

	&lt;div id=&quot;main&quot;&gt;
		&lt;h1&gt;Far far away…&lt;/h1&gt;
		&lt;p&gt;Far far away, behind the word mountains…&lt;/p&gt;
	&lt;/div&gt;

	&lt;div id=&quot;accessory&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Far far away…&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Separated they live…&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;A small river named…&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;

	&lt;div id=&quot;footer&quot;&gt;
		Visit the article…
	&lt;/div&gt;

&lt;/div&gt;</pre>
<p>After the (hopefully) self-explanatory simple reset (please check the full CSS in the example document), font properties and defining the links, I will define the look of my <code>body</code> element:</p>
<pre class="brush: css; title: ; notranslate">body {
	background: #E8EADD;
	color: #3C323A;
	padding: 20px; }</pre>
<p>After that, I will say that the main container <code>div</code> should be full width (100%) minus 40px and aligned horizontally in the middle of the viewport:</p>
<pre class="brush: css; title: ; notranslate">.wrapper {
	width: 1024px; /* Fallback for browsers that don't support the calc() function */
	width: -moz-calc(100% - 40px);
	width: calc(100% - 40px);
	margin: auto; }</pre>
<p>In the CSS above, I have also added a fallback width for browsers that don’t support the <code>calc()</code> function, and the vendor prefix for Firefox 4.</p>
<p>Following this, I will set the borders, width and margins of the main container <code>div</code>, and I will float it left:</p>
<pre class="brush: css; title: ; notranslate">#main {
	border: 8px solid #B8C172;
	float: left;
	margin-bottom: 20px;
	margin-right: 20px;
	padding: 20px;
	width: 704px; /* Fallback for browsers that don't support the calc() function */
	width: -moz-calc(75% - 20px*2 - 8px*2);
	width: calc(75% - 20px*2 - 8px*2); }</pre>
<p>So what is happening in this <code>calc()</code> function? I am stating that I want my container <code>div</code> to be 75% wide (75% of its parent container, remember), but from these 75% I need to subtract “<code>20px*2</code>” to account for the padding on each side, and “<code>8px*2</code>” to account for the border on each side.</p>
<p>Moving onto the sidebar, I want it to occupy the remaining 25% inside the parent container, but this value will have to allow for padding, borders and the margin of the sidebar <code>div</code> (20px).</p>
<pre class="brush: css; title: ; notranslate">#accessory {
	border: 8px solid #B8C172;
	float: right;
	padding: 10px;
	width: 208px; /* Fallback for browsers that don't support the calc() function */
	width: -moz-calc(25% - 10px*2 - 8px*2 - 20px);
	width: calc(25% - 10px*2 - 8px*2 - 20px); }</pre>
<p>Deconstructing “<code>calc(25% - 10px*2 - 8px*2 - 20px)</code>”, we have the original 25%, minus “<code>10px*2</code>” to account for the padding on each side, minus “<code>8px*2</code>” to account for the border on each side, minus “<code>20px</code>” to account for the main container’s right margin.</p>
<p>The footer is simply a full width <code>div</code>, I shan’t bore everyone by explaining that.</p>
<p>Because the sidebar becomes too small after a certain point, I’ve also included a simple media query that unfloats the main and sidebar containers, and recalculates their widths so they are 100% wide minus their respective padding and border values.</p>
<pre class="brush: css; title: ; notranslate">@media screen and (max-width: 768px) {
	#main, #accessory {
		float: none; }
	#main {
		margin-right: 0;
		width: -moz-calc(100% - 20px*2 - 8px*2);
		width: calc(100% - 20px*2 - 8px*2); }
	#accessory {
		width: -moz-calc(100% - 10px*2 - 8px*2);
		width: calc(100% - 10px*2 - 8px*2); }
}</pre>
<p>This is a very simplistic use case, but hopefully it’s enough to spike your interest and prompt you to find out more about wonderful <code>calc()</code>.</p>
<h3>Browser support</h3>
<p>Calc is supported by IE 9 and Firefox 4 (which requires the <code>-moz-calc</code> vendor property). I can understand, however, how this can be a bigger problem if compared to the relatively deficient browser support of things such as animations. While animations are accessory, incorrect measurements can break a site.</p>
<p>This does not mean though that we shouldn’t be trying these out. If Firefox and IE have made the effort to implement this, and these are the browsers with the biggest market share, I would suppose the others will follow suit (I’m not sure whether WebKit or Opera are working on this or not, but do let me know if they are).</p>
<p>In my example, I’ve opted for including fallback, absolute lengths for non-comforming browsers, which gives them a non-fluid layout. This might not be acceptable in your particular case though, but it is for my use case.</p>
<h3>Reference</h3>
<p>If you’d like to know more about <code>calc()</code>, head on to the following resources:</p>
<ul>
<li><a href="http://www.w3.org/TR/css3-values/#calc" rel="nofollow" >CSS3 Values and Units, W3C specification</a></li>
<li><a href="http://dev.w3.org/csswg/css3-values/#the-calc-min-and-max-functions" rel="nofollow" >CSS3 Values and Units, W3C Editor&#8217;s Draft specification</a></li>
<li><a href="https://developer.mozilla.org/en/CSS/-moz-calc" rel="nofollow" >-moz-calc on MDC Docs</a></li>
<li><a href="http://hacks.mozilla.org/2010/06/css3-calc/" rel="nofollow" >Firefox 4: CSS3 calc() announcement on Mozilla Hacks</a></li>
</ul>
<h3>Final note</h3>
<p>Along with few other CSS3 properties, <code>calc()</code> is one of those new pieces of CSS that can truly make our lives easier. I haven’t tested it in terms of performance, so I don’t know how big an impact all these calculations might have on the browser, but I’d guess it won’t be more consequential than all those transitions and transforms that everyone seems to be so happy to indiscriminately add to their sites.</p>
<p>So, have you used <code>calc()</code> on a project? Is this something you feel is a welcome addition to CSS? I’d love to hear your thoughts.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/the-wonderful-calc-function/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Are CSS Frameworks Evil?</title>
		<link>http://webdesignernotebook.com/css/are-css-frameworks-evil/</link>
		<comments>http://webdesignernotebook.com/css/are-css-frameworks-evil/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 21:48:17 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1361</guid>
		<description><![CDATA[CSS frameworks have a tendency to be dismissed by many CSS authors; code bloat and non-semantic class names are usually at the top of the list of reasons why. Even without ever using one, I shared the same opinion, but that might have changed after trying a few of them out while doing some research [...]]]></description>
			<content:encoded><![CDATA[<p>CSS frameworks have a tendency to be dismissed by many CSS authors; code bloat and non-semantic class names are usually at the top of the list of reasons why. Even without ever using one, I shared the same opinion, but that might have changed after trying a few of them out while doing some research recently…</p>
<p><span id="more-1361"></span></p>
<h3>Existing frameworks</h3>
<p>There&#8217;s an abundance of CSS frameworks out there, from the simpler ones that only provide layout solutions to ones that include forms, typography and fluid layout modules.</p>
<p>From what I can tell, designers and agencies that work with frameworks on a regular basis tend to use either <a href="http://www.blueprintcss.org/" rel="nofollow" ><strong>Blueprint CSS</strong></a> or <a href="http://960.gs/" rel="nofollow" ><strong>960 Grid System</strong></a> (often abbreviated to 960gs). <a href="http://developer.yahoo.com/yui/3/cssgrids/" rel="nofollow" ><strong>Yahoo!&#8217;s YUI Grids</strong></a> is also a popular one. These were the three frameworks I experimented with.</p>
<h3>Preconceptions</h3>
<p>I had frameworks all figured out: they were for CSS authors who wanted to go with the easy solution and not create their own CSS foundations, or for those who didn&#8217;t really want to understand how CSS works — basically, anyone looking for an <strong>easy solution</strong>.</p>
<p>If there is one thing I dislike it is purists who aren&#8217;t open to other people&#8217;s ideas and that never change their minds. I love CSS and I can be a purist in some cases, but I also understand that <strong>not everything can be perfect</strong> and sometimes stylesheets are messy. We all aspire to create beautiful, clean code, that is semantic and valid, but when working on real projects, that keep being updated, where more than one person at different times edits the CSS, each one with their interpretation of &#8216;perfect&#8217; and with their own different level of expertise and experience, <strong>efficiency usually takes precedence</strong> over the purity of the code.</p>
<p>But I digress. What I mean to say is that sometimes we can use the odd non-semantic class name and no puppies will die. This is what frameworks are often criticised for. Class names like &#8216;<code>grid_16</code>&#8216; or &#8216;<code>span-8</code>&#8216; are far from being ideal, but given the need for being adaptable to any kind of project, they make sense (in most cases at least).</p>
<p>These non-semantic class names can be paired with better ID names (like &#8216;<code>class="span-8" id="aside"</code>&#8216;) or, when using HTML5, with semantic element names.</p>
<p>While I was trying these frameworks out, I asked a few questions on Twitter (mainly complaints, to be fair), and, even though this is not scientific, most people seemed to <strong>reprove the use of frameworks</strong>. I seem to remember someone even saying they are ‘useless’, and many more negative comments. Two or three people said they used them though, and were very happy about that (opinions diverged on which one).</p>
<h3>Wireframing</h3>
<p>I always had the idea that frameworks would be quite useful to create wireframes on the browser, so that was what I decided to replicate with Blueprint, 960gs and YUI 3 Grids, using a <em>very</em> simple layout.</p>
<h4>Blueprint</h4>
<p>The Blueprint CSS framework was created by <a href="http://bjorkoy.com/" rel="nofollow" >Olav Bjørkøy</a> and released in August 2007. It is usually considered to be the most comprehensive CSS framework, since it caters not only for grid-based layout creation but provides, and has, a <strong>solid typographic foundation</strong>, considering aspects like vertical rhythm. It also provides a reset and print stylesheet, and basic styling for forms.</p>
<p><a href="http://www.blueprintcss.org/" rel="nofollow" ><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-1-blueprint.jpg" alt="" title="Blueprint CSS homepage" width="500" height="472" class="alignnone size-full wp-image-1368" /></a></p>
<p>The framework uses by default a 24-column layout (each column spans 30 pixels and has a right margin of 10 pixels) but you can create different layouts by using the compressor included in the files.</p>
<p>Using Blueprint is as easy as including a wrapper with a class of “<code>container</code>” surrounding the remaining blocks on the page. Depending on the width of each of the internal containers, you need to use a class of, for example, “<code>span-24</code>”, for a div that spans across the entire width of the page, or “<code>span-8</code>”, for a block that spans across 8. If the container is the last one within a particular container or column, it should also include a class of “<code>last</code>”. The HTML for a the layout above would look like this (I have omitted the content, of course):</p>
<pre class="brush: xml; title: ; notranslate">&lt;body&gt;
	&lt;div class=&quot;container&quot;&gt;

		&lt;div class=&quot;span-24 b&quot;&gt;
		&lt;/div&gt;

		&lt;div class=&quot;span-6 b&quot;&gt;
		&lt;/div&gt;

		&lt;div class=&quot;span-18 last&quot;&gt;

			&lt;div class=&quot;span-15&quot;&gt;

				&lt;div class=&quot;span-15 last b&quot;&gt;
				&lt;/div&gt;

				&lt;div class=&quot;span-9 b&quot;&gt;
				&lt;/div&gt;

				&lt;div class=&quot;span-6 last b&quot;&gt;
				&lt;/div&gt;

			&lt;/div&gt;

			&lt;div class=&quot;span-3 last&quot;&gt;
			&lt;/div&gt;

			&lt;div class=&quot;span-18 last b&quot;&gt;
			&lt;/div&gt;

		&lt;/div&gt;

	&lt;/div&gt;
&lt;/body&gt;</pre>
<p>I’ve also added a class “<code>b</code>” (pardon the presentational name) to the <code>div</code>s that have content so that I could add a light background and some bottom margin to preview the wireframe better (we’re just doing a quick example here, so it’s OK to include this directly in the head):</p>
<pre class="brush: css; title: ; notranslate">.b { background:#d4d4d4; margin-bottom:10px; }</pre>
<p>Here’s a screenshot of the completed wireframe:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-2-wireblueprint.jpg" alt="" title="Simple wireframe made with Blueprint CSS" width="500" height="346" class="alignnone size-full wp-image-1369" /></p>
<p>This took me <strong>less than 10 minutes</strong> to make (I know it’s pretty basic though), including having a quick read through the Getting Started guides.</p>
<h4>960gs</h4>
<p>The 960 Grid System CSS framework was developed by <a href="http://sonspring.com/" rel="nofollow" >Nathan Smith</a> and was released in March 2008. This framework was developed with a strong <strong>focus on the grid</strong>; even though it provides basic typographic styles, its main purpose is to  deliver a cross-browser foundation (it has full A-Grade browser support, <a href="http://developer.yahoo.com/yui/articles/gbs/" rel="nofollow" >as defined by Yahoo!</a>) that allows for many variations of the most common grid-based layouts.</p>
<p><a href="http://960.gs" rel="nofollow" ><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-3-906gs.jpg" alt="" title="906 Grid System homepage" width="500" height="472" class="alignnone size-full wp-image-1370" /></a></p>
<p>For 960gs I’m going with an even simpler layout — the main idea here is to show the differences between class naming and nesting from framework to framework.</p>
<p>The framework works, by default, on either a 12 or 16 column grid. We need to add a container surrounding the inner blocks with a class of “<code>container_16</code>” (or “<code>container_12</code>”); the inner containers should have classes of “<code>grid_16</code>”, “<code>grid_14</code>”, etc., depending on how many columns they span. Here is the final HTML markup for our simple layout:</p>
<pre class="brush: xml; title: ; notranslate">&lt;body&gt;
	&lt;div class=&quot;container_16&quot;&gt;
		&lt;div class=&quot;grid_16 b&quot;&gt;
			Header
		&lt;/div&gt;
		&lt;div class=&quot;grid_4 b&quot;&gt;
			Sidebar
		&lt;/div&gt;
		&lt;div class=&quot;grid_12 b&quot;&gt;
			Main content
		&lt;/div&gt;
		&lt;div class=&quot;grid_16 b&quot;&gt;
			Footer
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;</pre>
<p>And this what you should see:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-4-wire960gs.jpg" alt="" title="Wireframe created with the 960 Grid System framework" width="500" height="346" class="alignnone size-full wp-image-1371" /></p>
<p>As with Blueprint, there are several tools online that allow you to configure the framework to your needs. <a href="http://www.designinfluences.com/fluid960gs/" rel="nofollow" ><strong>Fluid 960 Grid System</strong></a> is based on the original 960 Grid System, but allows for fluid and fixed layouts, and includes basic styling for elements such as navigation, tables, forms, articles and typography.</p>
<h4>YUI 3 Grids</h4>
<p>The YUI 3 Grids framework is part of the Yahoo! User Interface Library (YUI). The library includes JavaScript resources as well as CSS (YUI 3 CSS also incorporates reset and typography stylesheets). It works in a similar way to the other frameworks presented in this chapter, with a difference: there is <strong>no predefined width</strong> for the main container, only predefined “units” in which a container can expand within another container.</p>
<p><a href="http://developer.yahoo.com/yui/3/cssgrids/" rel="nofollow" ><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-5-yui.jpg" alt="" title="YUI 3 Grids web page" width="500" height="472" class="alignnone size-full wp-image-1372" /></a></p>
<p>In this case, we need to add the desired width to the <code>body</code> element of our page, as such:</p>
<pre class="brush: css; title: ; notranslate">body {
  	 margin: auto;
  	 width: 960px;
}</pre>
<p>The “<code>margin: auto</code>” property will centre our content on the page. Next, as with the other frameworks, we need to include a wrapper container with the class “<code>yui3-g</code>”. The containers within it will take class names based on the percentage of the width they should fill (or “units”). So, for example, if the sidebar takes up one third of the total width, it should have a class of “<code>yui3-u-1-3</code>”, and if the main content area takes up two thirds of the total width, it should have a class of “<code>yui3-u-2-3</code>”. YUI comes with a set of predefined unit classes (which are listed in the framework’s website).</p>
<p>The final example would have the following HTML:</p>
<pre class="brush: xml; title: ; notranslate">&lt;body&gt;
	&lt;div class=&quot;yui3-g&quot;&gt;
		&lt;div class=&quot;yui3-u-1 b&quot;&gt;
			Header
		&lt;/div&gt;
		&lt;div class=&quot;yui3-u-1-3 b&quot;&gt;
			Sidebar
		&lt;/div&gt;
		&lt;div class=&quot;yui3-u-2-3 b&quot;&gt;
			Main content
		&lt;/div&gt;
		&lt;div class=&quot;yui3-u-1 b&quot;&gt;
			Footer
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;</pre>
<p>Looking like this:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-6-wireyui.jpg" alt="" title="Simple wireframe created with YUI 3 Grids" width="500" height="346" class="alignnone size-full wp-image-1373" /></p>
<p>Notice that YUI doesn’t have gutters between the columns — I see that as a downside.</p>
<h3>My favourite</h3>
<p>For me there&#8217;s a clear winner and it&#8217;s <strong>Blueprint</strong>. The guide was clear, it provides lots of tutorials and examples from within the front page of the website, and the fact that it provides a good typographic foundation is a major advantage.</p>
<p>Another advantage of Blueprint is the community behind it, which is constantly creating and releasing new plugins, themes and other tools that can be used in conjunction with the basic framework.</p>
<p>I felt <strong>960gs</strong>&#8216;s logic a lot harder to understand; it took me more than 30 minutes to figure out how the framework worked and finish the layout. If I&#8217;m going to use a framework I will be doing it to save time, so I didn&#8217;t find that experience very nice. Also, contrary to Blueprint&#8217;s website, 960gs&#8217;s didn&#8217;t have a clear &#8216;getting started&#8217; tutorial, so I had to look for articles outside of the site to &#8216;get started&#8217;. I do like the Fluid 960gs framework, but I&#8217;m not sure if there isn&#8217;t something similar for Blueprint.</p>
<p>Most people that I’ve talked to while doing this little experiment mentioned that they didn’t really appreciate frameworks, but the ones who did, swore by 960gs, so it might have been that I just wasn’t introduced to it the right (or simpler) way. There are beautiful websites built on top of this framework (a quick look at its website is enough proof), like the gorgeous Black Estate Vineyard:</p>
<p><a href="http://blackestate.co.nz/" rel="nofollow" ><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/09/image-7-blackestate.jpg" alt="" title="Black Estate Vineyard website" width="500" height="613" class="alignnone size-full wp-image-1374" /></a></p>
<p>The fact that <strong>YUI</strong> is adaptable to any width is a major plus, but the reduced amount of unit combinations made it a little uncomfortable to use, and I felt somewhat restricted as to what I could do with my layouts. If this is incorrect, I&#8217;d love it if someone would let me know, I couldn&#8217;t find a way around it easily in the getting started guide.</p>
<h3>Conclusion</h3>
<p>I&#8217;ve mentioned above that I believed CSS frameworks to be &#8216;the easy solution&#8217;. I still think that&#8217;s true, but I don&#8217;t see it as a bad thing: why spend hours creating perfectly hand-crafted CSS layouts when there are excellent foundations that we can build upon already out there? Life&#8217;s not just about coding (really) and there are better things that I can be doing with my time than creating problems for which there are solutions already.</p>
<p>This doesn&#8217;t mean, however, that I believe everyone should be using existing frameworks in their projects. Ideally, you&#8217;d be working with <strong>your own framework</strong> or template, adapted to your needs. It just means that I don&#8217;t think CSS frameworks should be treated like a bad thing and they can definitely be useful in some cases, or even as a base or inspiration for creating a custom framework. And I will certainly not condemn any designer or agency that uses out-of-the-box solutions, like Blueprint, because the benefits that you get from using those can surpass the downsides like verbose stylesheets and non semantic class names.</p>
<p>Don’t get me wrong: I thrive on a good piece of semantic HTML and CSS, and like most of you I also wanted to throw up the first time I looked at the non-semantic classes that these frameworks use. I will look at you sideways if your navigation is a paragraph rather than a list and I may unfollow you on Twitter if I know you’ve ever used class names like “<code>redLink</code>”. I still believe that the non-semantic class names are the <strong>least desirable feature</strong> of frameworks; ideally we shouldn&#8217;t have classes like that in our stylesheets, but I also think there are times when we need to be flexible and adapt ourselves and accept that things like this will happen.</p>
<p>Maybe they are a good solution for quick or <strong>low budget projects</strong>, or prototypes (although prototype code will often move on to production, so beware if you’re especially lazy, like me). I just thought this would be a good topic to discuss, and I guess I don’t mind saying that <a href="http://webdesignernotebook.com/tools/in-dreamweavers-defense/" rel="nofollow" >I like stuff people usually get repulsed by</a>, so here.</p>
<p>My verdict: no, frameworks are <em>not</em> evil.</p>
<p>So my question is, have you ever used a framework? Do you agree that they are a great tool, or have I gone crazy? I&#8217;d love to hear your thoughts.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/are-css-frameworks-evil/feed/</wfw:commentRss>
		<slash:comments>72</slash:comments>
		</item>
		<item>
		<title>My thoughts on LESS</title>
		<link>http://webdesignernotebook.com/css/my-thoughts-on-less/</link>
		<comments>http://webdesignernotebook.com/css/my-thoughts-on-less/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 00:10:36 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1327</guid>
		<description><![CDATA[I’ve started using LESS a few months ago on a few projects. LESS allows you to extend the way you write CSS, letting you use variables, nested selectors, operations and mixins. It sounds great — and it is great — but there are a few things that can make it work against you. These are [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started using <a href="http://lesscss.org/" rel="nofollow" >LESS</a> a few months ago on a few projects. LESS allows you to extend the way you write CSS, letting you use variables, nested selectors, operations and mixins. It sounds great — and it <em>is</em> great — but there are a few things that can make it work against you. These are some of my thoughts on LESS.</p>
<p><span id="more-1327"></span></p>
<h3>What is LESS?</h3>
<p>LESS — Leaner CSS — is, in the <a href="http://www.usabilitypost.com/2009/06/16/introducing-less-a-better-css/" rel="nofollow" >authors&#8217; own words</a>, a “<strong>new version of CSS</strong>” (better yet, of writing CSS), that is then compiled into “traditional” CSS using the LESS compiler.</p>
<p>There are 4 main things you can do with LESS that you can’t with normal CSS:</p>
<h4>1. Variables</h4>
<p>You can define a variable, such as “<code>@text-color</code>”, and use it throughout your stylesheet. If the colour of your text changes, you only need to change it once in your CSS — where the variable is initially defined.</p>
<h4>2. Nested selectors</h4>
<p>With nested selectors, instead of doing this and repeating yourself:</p>
<pre class="brush: css; title: ; notranslate">aside h1 { font-size: 24px; }
aside h2 { font-size: 18px; }</pre>
<p>You can have:</p>
<pre class="brush: css; title: ; notranslate">aside {
	h1 { font-size: 24px; }
	h2 { font-size: 18px; }
}</pre>
<h4>3. Operations</h4>
<p>You can add, subtract, divide and multiply using operations. Here’s a quick example:</p>
<pre class="brush: css; title: ; notranslate">@wrappers: 600px;

aside {
    width: @wrappers / 2;
}</pre>
<p>This is definitely not the best example, but it should be enough for you to get the point.</p>
<h4>4. Mixins</h4>
<p>Mixins work a lot like variables, but you can specify a whole class in one. For example:</p>
<pre class="brush: css; title: ; notranslate">.b-radius {
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
}

.box {
	.b-radius;
}</pre>
<p>From these examples, I suppose you can say that <em>LESS is actually more</em>. (I’m sorry, I couldn’t help myself.)</p>
<h3>This is not a &#8220;how to&#8221; guide</h3>
<p>The <a href="http://lesscss.org/docs" rel="nofollow" >official LESS documentation</a> is very clear on how to install it. I have to admit I usually stop reading instructions whenever &#8220;Terminal&#8221; is mentioned (and I know more people do), but I guess most CSS authors will be OK with it — if not, ask for help to your nearest web dev (or email me and I’ll give you the phone number of one).</p>
<p>After it’s installed, you’ll have <strong>two files</strong>: the .less file — this is the file you&#8217;ll be working with — and the compiled .css file.</p>
<p>There&#8217;s also <a href="http://incident57.com/less/" rel="nofollow" >LESS app</a>, that makes it easier to use LESS. And I suppose that some CMS and servers let you use LESS directly, but the point of this article is not to teach anyone how to install it — it&#8217;s to go through its good and bad points.</p>
<p>On to the important bit…</p>
<h3>How LESS can make your life easier</h3>
<p>This is a list of things that, in my opinion, <strong>make LESS worthwhile</strong> and can really simplify your CSS. These are the things that I usually miss the most when I’m not working on LESS files.</p>
<h4>1. Variables</h4>
<p>Surely when you are writing your CSS there are colours, measurements, etc. that you <strong>keep using over and over</strong>. For example, let&#8217;s say your brand colour is jade (very fashionable for Spring/Summer 2010). You may use it on various elements in your design, for example, the main text:</p>
<pre class="brush: css; title: ; notranslate">body {
    …
    color: #77b59d;
    …
}</pre>
<p>Or the borders of your posts:</p>
<pre class="brush: css; title: ; notranslate">article {
    …
    border-bottom: 1px solid #77b59d;
    …
}</pre>
<p>Or as the background of your footer:</p>
<pre class="brush: css; title: ; notranslate">footer {
    …
    background-color: #77b59d;
    …
}</pre>
<p>If someone has to edit the CSS file and doesn&#8217;t know exactly which colour he or she is supposed to be using — it may even be you a few months later —, what happens is that either you&#8217;ll spend some time scanning through the document until you find the colour, you&#8217;ll use Firebug or, if you like to complicate things, use xScope or take a screenshot and use Photoshop to detect the colour.</p>
<p>This is silly. You&#8217;ll end up with many similar colours instead of just one. (As a note, Dreamweaver lists all the colours that a site is using — you&#8217;d be surprised at how inconsistent some CSS authors can be when applying colour.)</p>
<p>Another thing that may happen is when you actually want to change this colour throughout your stylesheet: <strong>you&#8217;ll have to edit every instance of it</strong> — that&#8217;s painful.</p>
<p>With a variable, you can have this:</p>
<pre class="brush: css; title: ; notranslate">@main-color: #77b59d;

body {
    …
    color: @main-color;
    …
}

article {
    …
    border-bottom: 1px solid @main-color;
    …
}

footer {
    …
    background-color: @main-color;
    …
}</pre>
<p>Beware though: you can easily <strong>go overboard with variables</strong>. I have to confess I was inebriated in the beginning by the thought of never having to declare a colour, a padding value, etc. again, and started adding too many variables to my LESS files. It gets messy and complicated quickly. You&#8217;ll have to <strong>find a balance</strong>.</p>
<h4>2. Accessors</h4>
<p>If you only need to <strong>access something once</strong>, you probably don’t need a variable. If you&#8217;re pretty sure that that thing you need to access is, and will always be, directly linked to whichever thing you&#8217;re linking it to, you can use an accessor.</p>
<p>Let&#8217;s say you have a block with a heading and some text. You want the border of that box to always be the same colour as the heading. You can have this:</p>
<pre class="brush: css; title: ; notranslate">#sales {
    border-color: #ae7b2a;
}

#sales h2 {
    color: #sales['border-color'];
}</pre>
<p>Using accessors may be going a step too far in some cases, but in other cases it makes a lot of sense — I think they&#8217;re quite useful.</p>
<h4>3. Mixins</h4>
<p>One example: gradients. Let’s face it, they are <strong>an absolute pain to write</strong>. Take a look at how LESS makes it easier for you:</p>
<p>The mixin:</p>
<pre class="brush: css; title: ; notranslate">.grad-linear (@start:&quot;&quot;, @end:&quot;&quot;) {
    background: -webkit-gradient(linear, left top, left bottom, from(@start), to(@end));
    background: -moz-linear-gradient(-90deg,@start,@end);
}</pre>
<p>Using the mixin in your .less file:</p>
<pre class="brush: css; title: ; notranslate">nav {
	.grad-linear(#b3cdcc,#718a89);
}</pre>
<p>What your compiled .css file will show:</p>
<pre class="brush: css; title: ; notranslate">nav {
	background: -webkit-gradient(linear, left top, left bottom, from(#b3cdcc), to(#718a89));
	background: -moz-linear-gradient(-90deg, #b3cdcc, #718a89);
}</pre>
<p>Mixins are great for properties that still require that we add some vendor-specific code (like <code>border-radius</code>) or for the latest CSS3 gradients, transitions, etc.</p>
<p>I have to say mixins, especially when used for gradients and <code>border-radius</code>, are my favourite part of LESS.</p>
<h4>4. C-style comments</h4>
<p>Some people prefer these to typical CSS inline comments. I&#8217;m OK with either, but if you&#8217;re using LESS, you can have either this:</p>
<pre class="brush: css; title: ; notranslate">/* A normal CSS comment */</pre>
<p>Or this:</p>
<pre class="brush: css; title: ; notranslate">// A C-style CSS comment</pre>
<h4>5. Nesting (in some cases)</h4>
<p>Nesting is one of those things that makes you think LESS is amazing at first. Then you start using LESS and start nesting selectors, and change your mind.</p>
<p>The rare instance where I think nesting is useful is with link states in simple selectors. In LESS you can have this:</p>
<pre class="brush: css; title: ; notranslate">a {
    :link, :visited { text-decoration:none; color:#edd273; font-weight:bold; }
    :hover, :active, :focus { color:#edd273; border-bottom:1px solid #edd273; }
}</pre>
<p>And the output will be this:</p>
<pre class="brush: css; title: ; notranslate">a:link {
  text-decoration: none;
  color: #edd273;
  font-weight: bold;
}
a:visited {
  text-decoration: none;
  color: #edd273;
  font-weight: bold;
}
a:hover {
  color: #edd273;
  border-bottom: 1px solid #edd273;
}
a:active {
  color: #edd273;
  border-bottom: 1px solid #edd273;
}
a:focus {
  color: #edd273;
  border-bottom: 1px solid #edd273;
}</pre>
<p>There&#8217;s a lot of repetition in here, I know (I&#8217;ll mention that on the next section), but it&#8217;s nice nonetheless.</p>
<h3>How LESS can easily become a nightmare</h3>
<p>This is a list of things that I would either <strong>avoid</strong> doing in LESS or that just <strong>don’t work</strong> the way you’d expect them to (so, annoyances).</p>
<h4>1. Nesting (in most cases)</h4>
<p>As I just mentioned in the previous section, nesting looks nice at first, but it doesn&#8217;t work flawlessly.</p>
<p>One of the things that I&#8217;ve noticed for example, is that, even though you can have this: </p>
<pre class="brush: css; title: ; notranslate">nav {
  ul {
    li a {
      :link { color: red; }
    }
  }
}</pre>
<p>This won&#8217;t work (notice that now I&#8217;m using a direct child selector instead):</p>
<pre class="brush: css; title: ; notranslate">nav {
  ul {
    li &gt; a {
      :link { color: red; }
    }
  }
}</pre>
<p>For this last bit of CSS to work, you&#8217;ll have to do it like this (notice the extra &#8220;&amp;&#8221;):</p>
<pre class="brush: css; title: ; notranslate">nav {
  ul {
    li &gt; a {
      &amp;:link { color: red; }
    }
  }
}</pre>
<p>This not a problem with LESS, I guess it&#8217;s just not a very intuitive way of doing it just for using a different type of selector.</p>
<p>The main thing, however, that I think makes nesting a poor choice in most cases, is how it can make <strong>a mess out of specificity</strong> [here's <a href="http://www.smashingmagazine.com/2010/04/07/css-specificity-and-inheritance/" rel="nofollow" >a post I've written previously on specificity</a> and other matters].</p>
<p>Your first instinct is to nest everything inside the main blocks, like <code>aside</code>, <code>#sidebar</code>, <code>#news</code>, etc. But then you realise you need to reutilise a piece of the CSS for another area on the site. You make another nested selector for that new block, because you don&#8217;t want to go over that first nested block of CSS that you created in the first place. You&#8217;ll be left out with numerous <strong>redundant selectors</strong>, with <strong>very long selectors</strong> (because you don&#8217;t notice this until the compiler phase), and with the need to create <strong>overly specific selectors</strong> to override your initial ones (that shouldn&#8217;t have been so specific to begin with).</p>
<p>Nesting selectors is one of those cases where the phrase &#8220;<em>with great power comes great responsibility</em>&#8221; makes a lot of sense. Use it wisely and carefully.</p>
<h4>2. Changes made to the compiled file</h4>
<p>This isn&#8217;t a problem with LESS per se, but rather with your <strong>working process</strong>.</p>
<p>Even if you are the only person in charge of the CSS on a given project, it&#8217;s possible that someday you will leave, or hand the project over to someone else, so it&#8217;s a good thing to make sure that no-one is going to edit the compiled .css file directly instead of the .less one.</p>
<p>If this happens, and then after a while someone <em>does</em> use the .less file, when it compiles, it will <strong>override the changes made</strong> to the .css file. Then you&#8217;ll have to go back and fix it.</p>
<p>This is just a general problem with people: if there&#8217;s a chance that we can make a mistake, we will make it.</p>
<h4>3. Formatting</h4>
<p>The .css file that results from the compiler gives you back your CSS with no comments and single-line declarations (that have more than one property). It would be useful if you could have some control over this. For example, you may want to minify the CSS (although you could argue that this should be a completely separate step), keep comments in, have multi-line CSS, group selectors, etc.</p>
<p>I&#8217;m not entirely sure if this has been resolved, so if someone knows better, do let me know.</p>
<h4>4. Using Firebug</h4>
<p>I can&#8217;t work without Firebug, and one of the best things about it is knowing exactly which line you&#8217;re looking at. If you&#8217;re using LESS, that&#8217;s broken: Firebug <strong>shows you the line of the compiled .css file</strong>, not the original .less file you&#8217;re editing, which is basically useless.</p>
<h3>Conclusion</h3>
<p>I love LESS and I think it&#8217;s <strong>a pleasure to use</strong>, until you start trying to be too clever and things start getting messy. My advice is to use it with care, take advantage of its niceties but don&#8217;t go overboard.</p>
<p>I know there are lot <a href="https://less.tenderapp.com/discussions/problems" rel="nofollow" >more problems</a> (and probably good things too) that I haven’t referred. These are the ones that I’ve <strong>personally</strong> came across with; I try not to use LESS on larger projects and I usually don&#8217;t use <code>@import</code> on my stylesheets (especially smaller projects) — which I know can cause some problems.</p>
<p>I’d love to know what your thoughts are on this: have you used it? Why, or why not? Which problems have you encountered? Do you find it helpful or just plain silly?</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/my-thoughts-on-less/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Books: &#8220;HTML and CSS Web Standards Solutions&#8221;</title>
		<link>http://webdesignernotebook.com/reviews/web-standardistas/</link>
		<comments>http://webdesignernotebook.com/reviews/web-standardistas/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 19:15:04 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Project 52]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1308</guid>
		<description><![CDATA[The second book I&#8217;m reviewing is &#8220;HTML and CSS Web Standards Solutions&#8221;, by web standardistas Christopher Murphy and Nicklas Persson. What is the book about? The book provides the reader with a foundation in how to markup and style a web site — the right way. In the authors&#8217; own words this book is &#8220;a [...]]]></description>
			<content:encoded><![CDATA[<p>The second book I&#8217;m reviewing is <a href="http://www.amazon.com/HTML-CSS-Standards-Solutions-Standardistas/dp/1430216069/" rel="nofollow" >&#8220;HTML and CSS Web Standards Solutions&#8221;</a>, by web standardistas Christopher Murphy and Nicklas Persson.</p>
<p><span id="more-1308"></span></p>
<h3>What is the book about?</h3>
<p>The book provides the reader with a <strong>foundation</strong> in how to markup and style a web site — the right way. In the authors&#8217; own words this book is &#8220;a well-grounded, web standards-based approach <strong>in one package</strong>&#8220;.</p>
<p>Starting from the beginning, it explains the <strong>importance of solid, structured markup</strong> and of analysing a web site&#8217;s content before diving into the coding phase. It introduces the most important HTML tags and how to properly use them.</p>
<p>Following the HTML section of the book — which takes almost half of it — it dives into the CSS bit. Here it explains <strong>how to use CSS in a clean and effective way</strong> — just the way I like it :)</p>
<p>One of the most important aspects of this book is how it encourages the reader to <strong>continue to learn and explore</strong> — there is a very clear message that you can&#8217;t possibly learn everything from one book. It provides several paths in which the reader can further his or her knowledge and <strong>evolve</strong> as a web designer.</p>
<h3>Who is the book for?</h3>
<p>As I&#8217;ve mentioned above, the book is targeted at beginners — <strong>it doesn&#8217;t assume you know anything</strong> about HTML or CSS so everything is explained in a very clear and practical way.</p>
<p>I suppose it&#8217;s hard to assess whether the information would be easy to understand by an absolute beginner since I&#8217;m not one anymore (or at least I like to think I&#8217;m not). But every step of the book is so carefully explained, that I doubt anyone would have any problems.</p>
<p>Like Sam Brown mentioned in the title of his review, <a href="http://sam.brown.tc/entry/419/web-designers-who-can-t-code-need-to-read-this-book" rel="nofollow" >&#8220;Web designers who can&#8217;t code, need to read this book&#8221;</a>. I couldn&#8217;t agree more.</p>
<h3>A minor remark</h3>
<p>The only thing I would have changed, or better yet, added to the book would be a <strong>more detailed section on inheritance</strong>. This is, however, probably due to the fact that I just wrote <a href="http://www.smashingmagazine.com/2010/04/07/css-specificity-and-inheritance/" rel="nofollow" >a massive post about it</a> and all that information is fresh in my memory.</p>
<p>Inheritance is a fairly complicated topic and would probably not be relevant for this book; it&#8217;s one of the things that people can easily research on their own when any issues arise.</p>
<h3>Conclusion</h3>
<p>Reading this book felt like I was at the web design school I never had the change to attend. It is truly <strong>a course in a book</strong>: it explains the basics that every web designer should know — whether a coder or not.</p>
<p>The completed website that it provides the reader with at the end is invaluable, and I am not ashamed to admit that, even though I&#8217;m not within the book&#8217;s target audience, I&#8217;ve learned a few things I didn&#8217;t know, and remembered others I had forgotten.</p>
<p>I am lucky enough to know Christopher and Nicklas, the authors of this book, personally, and it was a pleasure to see that their charmingly friendly personalities show through in the writing of the book — which makes it an even more <strong>delightful read</strong>. Thoroughly recommended!</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/reviews/web-standardistas/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Little Known font-size-adjust CSS3 Property</title>
		<link>http://webdesignernotebook.com/css/the-little-known-font-size-adjust-css3-property/</link>
		<comments>http://webdesignernotebook.com/css/the-little-known-font-size-adjust-css3-property/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 22:45:32 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Project 52]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1287</guid>
		<description><![CDATA[Ever wanted to use fallback fonts on your CSS with different aspect ratios without them looking huge (or tiny)? The sparkling new CSS3 font-size-adjust property could do just that, maybe. What does font-size-adjust do? First, let me warn you: you will need to use Firefox to view the examples on this page properly. Yes, not [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to use fallback fonts on your CSS with different aspect ratios without them looking huge (or tiny)? The sparkling new CSS3 <code>font-size-adjust</code> property could do just that, maybe.</p>
<p><span id="more-1287"></span></p>
<h3>What does <code>font-size-adjust</code> do?</h3>
<p><em>First, let me warn you: you will need to use <strong>Firefox</strong> to view the examples on this page properly. Yes, not Safari, Firefox!</em></p>
<p>The <code>font-size-adjust</code> property allows you to specify an optimal aspect ratio <strong>for when a fallback font is used</strong>; if the substitute font has a different aspect ratio than the preferred one, the text’s <a href="http://en.wikipedia.org/wiki/X-height" rel="nofollow" >x-height</a> (roughly the size of its lowercase letters) will be preserved.</p>
<p>Take a look at the image bellow:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/03/fontsizeadjust-compare.png" alt="" title="Comparison of the aspect ratio of Baskerville and Georgia" width="390" height="279" class="alignnone size-full wp-image-1293" /></p>
<p>Baskerville and Georgia don’t have the same aspect ratio, so when font fallback occurs (if Baskerville is the optimal font), the text usually looks much bigger even at the same size.</p>
<p>By using <code>font-size-adjust</code>, the original <code>font-size</code> for the fallback fonts <strong>will be divided</strong> by the <code>font-size-adjust</code> value.</p>
<p><em>Do not confuse <code>font-size-adjust</code> with <code><a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/css/property/-webkit-text-size-adjust" rel="nofollow" >-webkit-text-size-adjust</a></code>, which is used to specify the size adjustment of text on the iPhone.</em></p>
<h3>How to determine the correct <code>font-size-adjust</code> value</h3>
<p>The example on the W3C specification is very clear:</p>
<blockquote cite="http://www.w3.org/TR/css3-fonts/#relative-sizing-the-font-size-adjust-pro"><p>
Authors can calculate the aspect value for a given font by comparing spans with the same content but different font-size-adjust properties. If the same font-size is used, the spans will match when the font-size-adjust value is accurate for the given font.
</p></blockquote>
<p>I’m going to basically repeat its example here.</p>
<p>Let’s take a look at the following code, in which we have a paragraph with two <code>span</code>s. </p>
<p>The CSS:</p>
<pre class="brush: css; title: ; notranslate">p { font-family:Times New Roman; font-size:400px; }

span { border:solid 1px red; }

.adjust { font-size-adjust:0.5; }</pre>
<p>The HTML:</p>
<pre class="brush: xml; title: ; notranslate">&lt;p&gt;&lt;span&gt;a&lt;/span&gt;&lt;span class=&quot;adjust&quot;&gt;a&lt;/span&gt;&lt;/p&gt;</pre>
<p>Both <code>span</code>s inherit the <code>font-family</code> from its parent (the <code>p</code> element), but the second <code>span</code> has the <code>font-size-adjust</code> property applied to it, with a <strong>random value</strong>.</p>
<p>If you check the <a href="http://webdesignernotebook.com/examples/font-size-adjust-test.html" rel="nofollow" >example page</a>, look at the example on the left: the red boxes don’t match size in height — the <code>font-size-adjust</code> value is wrong.</p>
<p><em>[Do all the boxes on the example page have the same height? What did I say? Firefox…]</em></p>
<p>After a few experiments, I’ve arrived at the value of “0.455”. Now here’s the CSS for the second example (on the right):</p>
<p>The CSS:</p>
<pre class="brush: css; title: ; notranslate">p { font-family:Times New Roman; font-size:400px; }

span { border:solid 1px green; }

.adjust { font-size-adjust:0.455; }</pre>
<p>If you go ahead to the <a href="http://webdesignernotebook.com/examples/font-size-adjust-test.html" rel="nofollow" >example page</a>, you will see that on the example with the green borders, both a’s bounding boxes have the same height — now we have the <strong>correct</strong> <code>font-size-adjust</code> value for our preferred font.</p>
<h3>An example</h3>
<p>Here’s <a href="http://webdesignernotebook.com/examples/font-size-adjust.html" rel="nofollow" >a quick example</a> I’ve created just to show this working on actual text.</p>
<p>The font stack consists of: Calibri, Lucida Sans and Verdana (and this is the order by which the fonts are displayed on the page).</p>
<p>Safari’s rendering of the page:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/03/font-size-adjust-safari.png" alt="" title="Font-size-adjust in Safari" width="597" height="361" class="alignnone size-full wp-image-1292" /></p>
<p>And Firefox’s:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2010/03/font-size-adjust-ff.png" alt="" title="Font-size-adjust in Firefox" width="597" height="357" class="alignnone size-full wp-image-1291" /></p>
<p>As you can see, Firefox maintains <strong>the same x-height</strong> independent of which font is being used.</p>
<p>I’m not concerned with the text not being aligned, the purpose of this example is to show how <code>font-size-adjust</code> can affect the <strong>consistency of the font size and the font&#8217;s legibility</strong>.</p>
<p>Also, even though the first <code>div</code> has the correct font stack, I had to manually specify Lucida Sans and Verdana for the other <code>div</code>s, so you (and I) can see the difference even if we have all three fonts installed.</p>
<h3>Last comments</h3>
<p>I guess using this property may eventually have some negative implications on how typography is treated throughout a website, but that can be the topic for another post — the main goal here is <strong>just to showcase</strong> a quite obscure CSS3 property that may be useful in some cases.</p>
<p>I confess I haven’t tested it on a “real” project yet, so I’d be happy to hear your thoughts.</p>
<p>This is, for now, only supported by Firefox for Windows from version 1.0 and from 3.0 on all platforms. There is a <a href="https://bugs.webkit.org/show_bug.cgi?id=15257" rel="nofollow" >bug filed for Webkit</a> to fix this issue though.</p>
<h3>References and further reading</h3>
<ul>
<li><a href="http://www.w3.org/TR/css3-fonts/#relative-sizing-the-font-size-adjust-pro" rel="nofollow" >Relative sizing: the ‘font-size-adjust’ property — CSS Fonts Module Level 3</a></li>
<li><a href="https://developer.mozilla.org/samples/cssref/font-size-adjust.html" rel="nofollow" >CSS Examples: font-size-adjust — Mozilla Developer Center</a></li>
<li><a href="https://developer.mozilla.org/en/CSS/font-size-adjust" rel="nofollow" >font-size-adjust — Mozilla Developer Center</a></li>
<li><a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28Cascading_Style_Sheets%29" rel="nofollow" >Comparison of layout engines (Cascading Style Sheets) — Wikipedia</a></li>
<li><a href="http://dbaron.org/log/20080613-firefox3-css#font-size-adjust" rel="nofollow" >Some new CSS features in Firefox 3 — David Baron&#8217;s Weblog</a></li>
<li>And another CSS fonts-related article that might interest you (by me): <a href="http://www.smashingmagazine.com/2010/03/01/css-and-the-future-of-text/" rel="nofollow" >The Future Of CSS Typography</a> — on Smashing Magazine</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/the-little-known-font-size-adjust-css3-property/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>A Quick Note About the :empty Pseudo-class</title>
		<link>http://webdesignernotebook.com/css/a-quick-note-about-the-empty-pseudo-class/</link>
		<comments>http://webdesignernotebook.com/css/a-quick-note-about-the-empty-pseudo-class/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 23:34:02 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Project 52]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1264</guid>
		<description><![CDATA[I&#8217;m in love with the simplicity that CSS3 selectors can bring to our stylesheets. Here&#8217;s a brief explanation of one of my favourites: the :empty pseudo-class. What is the :empty pseudo-class Here is the definition taken from the W3C Selectors Level 3 specification: The :empty pseudo-class represents an element that has no children at all. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in love with the simplicity that CSS3 selectors can bring to our stylesheets. Here&#8217;s a brief explanation of one of my favourites: the <code>:empty</code> pseudo-class.</p>
<p><span id="more-1264"></span></p>
<h3>What is the <code>:empty</code> pseudo-class</h3>
<p>Here is the definition taken from the <a href="http://www.w3.org/TR/css3-selectors/#empty-pseudo" rel="nofollow" >W3C Selectors Level 3 specification</a>:</p>
<blockquote cite="http://www.w3.org/TR/css3-selectors/#empty-pseudo"><p>
The <code>:empty</code> pseudo-class represents an element that has no children at all.
</p></blockquote>
<p>Seems easy enough, right? That&#8217;s because it is. The <code>:empty</code> pseudo-class is going to target elements that are completely empty; for example, an empty paragraph:</p>
<pre class="brush: xml; title: ; notranslate">&lt;p&gt;&lt;/p&gt;</pre>
<p>Or an empty table cell:</p>
<pre class="brush: xml; title: ; notranslate">&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
<p>It won&#8217;t target this paragraph though (there is a space within the <code>p</code> tag, therefore it isn&#8217;t <em>empty</em>):</p>
<pre class="brush: xml; title: ; notranslate">&lt;p&gt; &lt;/p&gt;</pre>
<h3>A practical example</h3>
<p>So when can this selector be useful?</p>
<p>Image you&#8217;re styling a table and some of the data cells have no content — you can style them differently using the magic <code>:empty</code> pseudo-class.</p>
<p>Let&#8217;s take the table I&#8217;ve created for the <a href="http://webdesignernotebook.com/css/a-beautiful-table/" rel="nofollow" >Adding Style with CSS: A Beautiful Table</a> article. I&#8217;m going to use the same CSS, but change the data to make it simpler (the data I&#8217;ve added makes no sense, but you get the point…). I&#8217;m also going to remove the content in a few cells, to make this example relevant.</p>
<p>So this is our markup:</p>
<pre class="brush: xml; title: ; notranslate">&lt;table&gt;

	&lt;caption&gt;A simple table&lt;/caption&gt;

	&lt;thead&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;col&quot; rowspan=&quot;2&quot;&gt;Some headings&lt;/th&gt;
			&lt;th scope=&quot;col&quot; colspan=&quot;4&quot;&gt;More headings&lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;col&quot;&gt;Great&lt;/th&gt;
			&lt;th scope=&quot;col&quot;&gt;Brilliant&lt;/th&gt;
			&lt;th scope=&quot;col&quot;&gt;Genius&lt;/th&gt;
			&lt;th scope=&quot;col&quot;&gt;Good&lt;/th&gt;
		&lt;/tr&gt;
	&lt;/thead&gt;

	&lt;tfoot&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;row&quot;&gt;Interesting totals&lt;/th&gt;
			&lt;td&gt;155&lt;/td&gt;
			&lt;td&gt;165&lt;/td&gt;
			&lt;td&gt;70&lt;/td&gt;
			&lt;td&gt;140&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tfoot&gt;

	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;row&quot;&gt;Curious&lt;/th&gt;
			&lt;td&gt;5&lt;/td&gt;
			&lt;td&gt;35&lt;/td&gt;
			&lt;td&gt;50&lt;/td&gt;
			&lt;td&gt;15&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;row&quot;&gt;Awesome&lt;/th&gt;
			&lt;td&gt;75&lt;/td&gt;
			&lt;td&gt;90&lt;/td&gt;
			&lt;td&gt;&lt;/td&gt;
			&lt;td&gt;5&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;row&quot;&gt;Fabulous&lt;/th&gt;
			&lt;td&gt;30&lt;/td&gt;
			&lt;td&gt;&lt;/td&gt;
			&lt;td&gt;20&lt;/td&gt;
			&lt;td&gt;80&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;th scope=&quot;row&quot;&gt;Nice&lt;/th&gt;
			&lt;td&gt;45&lt;/td&gt;
			&lt;td&gt;40&lt;/td&gt;
			&lt;td&gt;&lt;/td&gt;
			&lt;td&gt;40&lt;/td&gt;
		&lt;/tr&gt;

	&lt;/tbody&gt;

&lt;/table&gt;</pre>
<p>This is what I&#8217;m going to add to the CSS:</p>
<pre class="brush: css; title: ; notranslate">tbody td:empty {
	background: #EFEFEF;
	}</pre>
<p>And now the empty cells are styled differently! I don&#8217;t think this could have been much easier.</p>
<p>Also, if you really need to ask, this selector works on the latest versions of Firefox, Safari, Chrome and Opera. It will probably work on Internet Explorer 9, like most CSS3 selectors will. (The first person to point out the obvious, will be directed to <a href="http://trentwalton.com/2010/03/08/quoting-lebowski/" rel="nofollow" >this link</a>. — Thanks, <a href="http://jackosborne.co.uk/" rel="nofollow" >Jack</a>, for helping me remember the link!)</p>
<p>Here&#8217;s the example:</p>
<p><a href="http://webdesignernotebook.com/examples/empty-selector.html" rel="nofollow" class="example" >View example</a></p>
<p>So, will you be using this selector any time soon?</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/a-quick-note-about-the-empty-pseudo-class/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Book Review: &#8220;CSS Mastery — 2nd Edition&#8221;</title>
		<link>http://webdesignernotebook.com/reviews/css-mastery/</link>
		<comments>http://webdesignernotebook.com/reviews/css-mastery/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 19:39:30 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Project 52]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1159</guid>
		<description><![CDATA[I&#8217;m frequently confronted with the question of &#8220;which CSS books would you recommend?&#8221; and CSS Mastery is always at the top of the list. Here&#8217;s the audio review I did for the Boagworld podcast. The audio Listen! Transcript If you&#8217;d rather read, here&#8217;s the transcript of the review: Hi, my name is Yaili and I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m frequently confronted with the question of &#8220;which CSS books would you recommend?&#8221; and <a href="http://www.amazon.com/CSS-Mastery-Advanced-Standards-Solutions/dp/1430223979/" rel="nofollow" >CSS Mastery</a> is always at the top of the list. Here&#8217;s the audio review I did for the <a href="http://boagworld.com/reviews/css-mastery-2" rel="nofollow" >Boagworld podcast</a>.</p>
<p><span id="more-1159"></span></p>
<h3>The audio</h3>
<p><object data="http://boos.audioboo.fm/swf/fullsize_player.swf" height="129" id="iefix1" type="application/x-shockwave-flash" width="400"><param name="movie" value="http://boos.audioboo.fm/swf/fullsize_player.swf" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="bgColor" value="#FFFFFF" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="window" /><param name="FlashVars" value="mp3Author=yaili&amp;mp3LinkURL=http%3A%2F%2Faudioboo.fm%2Fboos%2F93079-css-mastery-2nd-edition-review&amp;mp3Title=CSS+Mastery+2nd+Edition+%E2%80%94+Review&amp;mp3Time=07.35pm+24+Jan+2010&amp;mp3=http%3A%2F%2Faudioboo.fm%2Fboos%2F93079-css-mastery-2nd-edition-review.mp3" /><a href="http://audioboo.fm/boos/93079-css-mastery-2nd-edition-review.mp3" rel="nofollow" >Listen!</a></object></p>
<h3>Transcript</h3>
<p><strong>If you&#8217;d rather read, here&#8217;s the transcript of the review:</strong></p>
<p>Hi, my name is Yaili and I&#8217;ll be reviewing the Second Edition of CSS Mastery, by Andy Budd.</p>
<h4>Who is the book for?</h4>
<p>The book states that it&#8217;s for &#8220;anybody with a basic knowledge of HTML and CSS&#8221; and experts. I&#8217;d say it&#8217;s more for the first case, but I&#8217;ll expand on that later.</p>
<p>There are lots of useful tips and tricks, that I&#8217;m sure you&#8217;ll use over and over, explained in a solid and easy to understand way. The fact that the examples can be seen online and that there are files that can be downloaded is great.</p>
<h4>It&#8217;s a second edition</h4>
<p>When I read the first edition, I was just starting to work with CSS, and CSS was still a bit of a mystery to me. I remember reading some things that I thought to be pure magic and that seemed very complicated, but now I realise they are used by any good CSS coder. So, at the time, the book opened my eyes to those techniques and to the possibilities of what could be done with CSS.</p>
<h4>Content</h4>
<p>The book covers subjects from the beginning to a more advanced level.</p>
<p>It starts with the importance of semantic HTML, how to set good foundations. It takes a very brief look into microformats and HTML5 as well.</p>
<p>Then it moves onto selectors, with some more advanced and CSS3 ones — but it doesn&#8217;t go very deep into that area to be honest.</p>
<p>It explains the box model, which is rather important, very well. Liquid and elastic layouts.</p>
<p>Some more advanced techniques, like sliding doors and even multiple backgrounds, which is quite refreshing. Opacity and rgba colours.</p>
<p>There are some clever uses for the :target pseudo-class and attribute selectors. Some webkit proprietary code like gradients and reflections.</p>
<p>It also explains how to style lists and navigation. I would have liked to see a larger section for definition lists, because there&#8217;s only a small section and it sounds a bit negative (or even dismissive) and I don&#8217;t think it makes them justice.</p>
<p>There are some negative comments on CSS frameworks. Which I frankly agree with.</p>
<p>A good introduction to the IE layout issue. Some common browser bugs and how to fix them. And how to work with graded browser support.</p>
<p>Then on the examples, at certain points they can be a little repetitive, but there&#8217;s an interesting discussion about website widths, a brief example of using jQuery, which is rather nice.</p>
<h4>Conclusion</h4>
<p>In conclusion, as someone who had already read the book, reading it again was good, as there are always things that you forget or that you weren&#8217;t aware of, even though my experience now is completely different, and I can be a little more critical about it.</p>
<p>If I could change something in the book, I think I&#8217;d change the naming of CSS3 — in the specs it&#8217;s always mentioned with no spaces, and in the book it has a space between the second &#8220;S&#8221; and the number &#8220;3&#8243;. I know it sounds nitpicky, but it&#8217;s rather annoying for me, for some reason…</p>
<p>Also, there are some mentions to browsers that are already dated, even though the book is fairly recent (like &#8220;Safari 4 beta&#8221;, which is already out of Beta). But that&#8217;s just something that happens in our industry — things move too quickly. I&#8217;m just being nitpicky again.</p>
<p>So, have <em>I</em> learned anything from this second edition? I did learn a few things, but not much. I already use or know most of the techniques. But would someone starting to work with CSS learn anything from the book? Definitely yes. I used to always recommend the first edition whenever someone asked me for book recommendations, and I will keep recommending it with the second edition. It&#8217;s a must-have.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/reviews/css-mastery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://audioboo.fm/boos/93079-css-mastery-2nd-edition-review.mp3" length="2928768" type="audio/mpeg" />
		</item>
		<item>
		<title>The CSS3 :target Pseudo-class And CSS Animations</title>
		<link>http://webdesignernotebook.com/css/the-css3-target-pseudo-class-and-css-animations/</link>
		<comments>http://webdesignernotebook.com/css/the-css3-target-pseudo-class-and-css-animations/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 07:30:05 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Project 52]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1140</guid>
		<description><![CDATA[It&#8217;s no secret that I&#8217;m always looking for an easy way out using CSS instead of trying to replicate things with convoluted code — there are so many underused techniques that we could be applying to our designs as an enhancement layer! In this experience, I take a brief look into the :target pseudo-class and [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s no secret that I&#8217;m always looking for an easy way out using CSS instead of trying to replicate things with convoluted code — there are so many underused techniques that we could be applying to our designs as an enhancement layer! In this experience, I take a brief look into the <code>:target</code> pseudo-class and a very simple CSS animation.</p>
<p><span id="more-1140"></span></p>
<h3>The :target pseudo-class</h3>
<p>We often use <strong>fragment identifiers</strong> in our code — usually to point to a specific element on a page, represented by a &#8220;#&#8221; and an anchor. When we click on a link that ends with a fragment identifier (for example, <a href="http://en.wikipedia.org/wiki/Lost_%28TV_series%29#Fandom_and_popular_culture" rel="nofollow" >this one</a>), that element we are pointing to becomes the <strong>target</strong> (hence <code>:target</code>).</p>
<p>This <code>:target</code> pseudo-class can be styled, just like we style the <code>:hover</code> or <code>:active</code> pseudo-classes on links.</p>
<p>To see an example in the wild, go to Wikipedia and click on a reference link (for example, <a href="http://en.wikipedia.org/wiki/Lost_%28TV_series%29#cite_note-16" rel="nofollow" >this one</a>). If you are using a good browser, you will see it has a light blue background; and if you look at the CSS, you will see this:</p>
<pre class="brush: css; title: ; notranslate">ol.references &gt; li:target, sup.reference:target, span.citation:target, cite:target  {
background-color:#DDEEFF;
}</pre>
<p>Pretty easy, right?</p>
<h3>Our example</h3>
<p>If you&#8217;re impatient, you can take a look at the final example now (use Safari):</p>
<p><a href="/examples/target.html" rel="nofollow"  class="example">View example</a></p>
<p>I&#8217;m going to create a simple list of links (using fragment identifiers) to blocks of text bellow them. Here&#8217;s the markup:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;content&quot;&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;#b1&quot;&gt;Block 1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#b2&quot;&gt;Block 2&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#b3&quot;&gt;Block 3&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#b4&quot;&gt;Block 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;b1&quot;&gt;
	&lt;p&gt;One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. &quot;What's happened to me? &quot; he thought.&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;b2&quot;&gt;
	&lt;p&gt;The quick, brown fox jumps over a lazy dog. DJs flock by when MTV ax quiz prog. Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph, for quick jigs vex! Fox nymphs grab quick-jived waltz. Brick quiz whangs jumpy veldt fox. Bright vixens jump; dozy fowl quack.&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;b3&quot;&gt;
	&lt;p&gt;Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;b4&quot;&gt;
	&lt;p&gt;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.&lt;/p&gt;
&lt;/div&gt;

&lt;/div&gt;</pre>
<h3>The basic CSS</h3>
<p>First, we need to cover the basics. I&#8217;ll use a very <strong>simple reset</strong> for this example, but you should use a proper one in your projects. I&#8217;ll just set the <code>font-size</code>, <code>line-height</code>, <code>font-family</code> and reset <code>padding</code> and <code>margin</code> for the elements we are using:</p>
<pre class="brush: css; title: ; notranslate">body {
	font:62.5%/1.5 Cambria,Georgia,&quot;Times New Roman&quot;,Times,serif;
	}
div, ul, li, a, p {
	padding:0; margin:0;
	}</pre>
<p>Second, I will quickly style the <strong>container</strong> <code>div</code> &#8220;<code>content</code>&#8220;:</p>
<pre class="brush: css; title: ; notranslate">#content {
	width:500px;
	margin:auto;
	font-size:1.4em;
	}</pre>
<p>Third, the rest of the elements. I will:</p>
<ol>
<li>Add a small bottom margin to the list and to each block of text.</li>
<li>Remove the bullets from our list — we don&#8217;t need them for the example.</li>
<li>Add some padding and a light border to the blocks of text.</li>
<li>Make the first line of each paragraph in small caps. Just because I can.</li>
</ol>
<p>Notice I&#8217;m using the <a href="http://www.w3.org/TR/2009/PR-css3-selectors-20091215/#child-combinators" rel="nofollow" ><strong>child combinator</strong></a> (or selector) to make sure the <code>div</code>&#8216;s I&#8217;m targeting are the ones that are <strong>direct descendants</strong> of the main &#8220;<code>content</code>&#8221; <code>div</code>. So if, for some reason, I were to have <code>div</code>&#8216;s inside the blocks of text, they wouldn&#8217;t be affected. Also, I don&#8217;t have to give these <code>div</code>&#8216;s a class or target them by their <code>id</code>&#8216;s.</p>
<pre class="brush: css; title: ; notranslate">ul, div &gt; div {
	margin-bottom:1em;
	}
li {
	list-style:none;
	}
div &gt; div {
	padding:1em;
	border:1px solid #ffffd3;
	}
div &gt; div p:first-line {
	font-variant:small-caps;
	font-size:1.2em;
	}</pre>
<h3>The juicy bit</h3>
<p>Now I&#8217;m going to style the <code>:target</code> pseudo-class. First, I&#8217;ll add a slightly <strong>darker border</strong> than the non-targeted <code>div</code>&#8216;s:</p>
<pre class="brush: css; title: ; notranslate">div &gt; div:target {
	border:1px solid #dac89d;
	}</pre>
<p>Enters the CSS animation. To create an animation you need two things: <strong>a definition</strong> of what effect the animation produces and <strong>a call</strong> to the animation from the element you want to animate.</p>
<p><strong>Let&#8217;s define the animation first.</strong></p>
<p>I&#8217;ll define the animation by setting up keyframes at certain points. In this case, I want the background to start as white, then fade to a light yellow, then back to white — I will need <strong>3 different steps</strong> (or keyframes).</p>
<p>Imagine each step is a simple selector, but instead of having for example this:</p>
<pre class="brush: css; title: ; notranslate">div {
	background: red;
	}</pre>
<p>we need to specify a moment in time (using percentages, or just &#8220;<code>to</code>&#8221; and &#8220;<code>from</code>&#8221; if we only need &#8220;<code>0%</code>&#8221; and &#8220;<code>100%</code>&#8220;):</p>
<pre class="brush: css; title: ; notranslate">10% {
	background: red;
	}</pre>
<p>Also, here I will <strong>name my animation</strong>. I will call it &#8220;<code>target</code>&#8220;:</p>
<pre class="brush: css; title: ; notranslate">@-webkit-keyframes target {
	from { background:#ffffff; }
	50% { background:#ffffd3; }
	to { background:#ffffff; }
	}</pre>
<p>So, the animation is defined, now we need to call it from the <code>:target</code> selector. We can either set each property separately, or use the shorthand version. Let&#8217;s see the full code:</p>
<pre class="brush: css; title: ; notranslate">div &gt; div:target {
	border:1px solid #dac89d;
	-webkit-animation-name:target;
	-webkit-animation-duration:.5s;
	-webkit-animation-iteration-count:1;
	-webkit-animation-direction:linear;
	}</pre>
<p>The <code>-webkit-</code> bits should be self-explanatory. We need to specify the animation&#8217;s name (&#8220;<code>target</code>&#8220;), it&#8217;s duration (&#8220;<code>.5s</code>&#8220;, half a second), how many times it should be repeated (&#8220;<code>1</code>&#8220;) and it&#8217;s direction (&#8220;<code>linear</code>&#8220;).</p>
<p>The <strong>shorthand</strong> version looks like this instead:</p>
<pre class="brush: css; title: ; notranslate">div &gt; div:target {
	border:1px solid #dac89d;
	-webkit-animation:target .5s linear;
	}</pre>
<p>Much simpler! Because we only want the animation to repeat once, we can even not specify the &#8220;<code>1</code>&#8221; in this case (if you wanted to, you could have it right after the &#8220;<code>.5s</code>&#8220;). Let&#8217;s say you want the animation to repeat twice, you would specify it like this:</p>
<pre class="brush: css; title: ; notranslate">div &gt; div:target {
	border:1px solid #dac89d;
	-webkit-animation:target .5s 2 linear;
	}</pre>
<h3>The end</h3>
<p>I hope you enjoyed this brief tutorial. There are endless possibilities for CSS animation and for more advanced CSS selectors, but I feel that the ones I&#8217;m showing here can actually be used on real projects with <strong>no damage for users</strong> browsing the web with less friendly browsers.</p>
<p>Do you agree? Have you used the <code>:target</code> pseudo-class on your projects? How about CSS animation?</p>
<p><em>Note: This animation is only visible on Safari (and Chrome, like <a href="http://webdesignernotebook.com/css/the-css3-target-pseudo-class-and-css-animations/#comment-4768" rel="nofollow" >Dougal kindly pointed out</a>!). The <code>:target</code> pseudo-class is not yet supported by Internet Explorer. Firefox and Opera will just show the darker border when you click on the links, but that is a good compromise.</em></p>
<h3>Resouces</h3>
<ul>
<li><a href="http://webkit.org/blog/324/css-animation-2/" rel="nofollow" >CSS Animation — Surfin&#8217; Safari Blog</a></li>
<li><a href="http://www.w3.org/TR/2009/PR-css3-selectors-20091215/#target-pseudo" rel="nofollow" >The target pseudo-class :target — W3C Specification</a></li>
</ul>
<p><em><strong>Update, 10 December 2011:</strong> <a href="http://webhostinggeeks.com/science/target-pseudo-ro" rel="nofollow" >Romanian translation of this web page</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/the-css3-target-pseudo-class-and-css-animations/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Remembering: The CSS3 Multi-Column Layout Module</title>
		<link>http://webdesignernotebook.com/css/remembering-the-css3-multi-column-layout-module/</link>
		<comments>http://webdesignernotebook.com/css/remembering-the-css3-multi-column-layout-module/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 19:55:58 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=1055</guid>
		<description><![CDATA[Because I will not shut up about CSS3, this time I&#8217;ve decided to show you a little bit of the multi-column layout module. This module allows you to layout the content of an element in multiple columns, like flowing text on a newspaper-type layout. CSS Modules Just to briefly make sure everybody understands what I [...]]]></description>
			<content:encoded><![CDATA[<p>Because I will <em>not</em> shut up about CSS3, this time I&#8217;ve decided to show you a little bit of the multi-column layout module. This module allows you to layout the content of an element in multiple columns, like flowing text on a newspaper-type layout.</p>
<p><span id="more-1055"></span></p>
<h3>CSS Modules</h3>
<p>Just to briefly make sure everybody understands what I mean by &#8220;modules&#8221;, <strong>the development of CSS3 has been divided in different Modules</strong>. For example, there is a <a href="http://www.w3.org/TR/css3-selectors/" rel="nofollow" >Selectors Module</a>, a <a href="http://www.w3.org/TR/css3-values/" rel="nofollow" >Values and Units Module</a>, a <a href="http://www.w3.org/TR/css3-background/" rel="nofollow" >Backgrounds and Borders Module</a>, etc.</p>
<p>Some of these Modules are at a more advanced stage of development and closer to being final than others. You can take a look at the <a href="http://www.w3.org/Style/CSS/current-work.html" rel="nofollow" >Current Work table here</a>.</p>
<h3>Browser support</h3>
<p>Let&#8217;s get this straight right away: <strong>only Safari and Firefox</strong> are currently supporting (some) of this module&#8217;s features, namely the properties <code>column-count</code>, <code>column-width</code>, <code>column-gap</code> and <code>column-rule</code>. Other browsers will render the content as if there were no columns at all.</p>
<p>There are more properties on the specs (and Safari supports a few more), but I&#8217;ll only mention these in this article, so we can all get a taste of what&#8217;s goin&#8217; on.</p>
<p>Also, I&#8217;ve picked this particular module, because it&#8217;s one of the few that is actually <a href="http://www.w3.org/Style/CSS/current-work.html#multicol" rel="nofollow" >in &#8220;Last Call&#8221; status</a>, so it&#8217;s closer to being finished than others.</p>
<h3>The markup</h3>
<p>For this example I grabbed some text from the excellent <a href="http://www.blindtextgenerator.com/" rel="nofollow" >Blind Text Generator</a> and created a basic page with some <code>div</code>s and paragraphs.</p>
<p>Here&#8217;s an example of one of the<code> div</code>s:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;text1&quot;&gt;

	&lt;p&gt;One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.&lt;/p&gt;

	&lt;p&gt;His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. &quot;What's happened to me? &quot; he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls.&lt;/p&gt;

	&lt;p&gt;A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.&lt;/p&gt;

	&lt;p&gt;Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. &quot;How about if I sleep a little bit longer and forget all this nonsense&quot;, he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.&lt;/p&gt;

&lt;/div&gt;</pre>
<h3>The CSS</h3>
<p>I&#8217;m just going to quickly show what each of the properties does. To use them, we&#8217;ll need to apply <a href="http://reference.sitepoint.com/css/vendorspecific" rel="nofollow" >vendor-specific properties</a>: for Safari the properties will be prefixed with <code>-webkit-</code> and for Firefox with <code>-moz-</code>. Annoying, but nothing we&#8217;re not used to, right?</p>
<p>Please follow the examples below <a href="http://webdesignernotebook.com/examples/css3-layout.html" rel="nofollow" >on this page</a>.</p>
<h4><code>column-width</code></h4>
<p>The CSS for our first <code>div</code> will be the following:</p>
<pre class="brush: css; title: ; notranslate">#text1 {
	-webkit-column-width: 200px;
	-moz-column-width: 200px;
	column-width: 200px;
	}</pre>
<p>This will create <strong>200px wide columns</strong> until the width of the page is filled, with <strong>no gap</strong> between the columns.</p>
<p>Each column within the element is called a <strong>column box</strong>. A column box doesn&#8217;t have its own properties, like background, padding or margins (at least not for now, but that may change for future specs). Also, all columns within a row have the same width and the same height.</p>
<p>The <code>column-width</code> property is <strong>not definitive—it is actually the optimal size</strong> we want the columns to have, but that may vary if the container is wider or narrower than it would be required to fit those measures.</p>
<h4><code>column-gap</code> and <code>column-rule</code></h4>
<p>Now let&#8217;s add some space between the columns and a nice rule, shall we?</p>
<pre class="brush: css; title: ; notranslate">#text2 {
	-webkit-column-width: 390px;
	-webkit-column-gap: 20px;
	-webkit-column-rule: 1px solid #000000;
	-moz-column-width: 390px;
	-moz-column-gap: 20px;
	-moz-column-rule: 1px solid #000000;
	column-width: 390px;
	column-gap: 20px;
	column-rule: 1px solid #000000;
	}</pre>
<p>In this example, we are defining a gap between each column of 20px and also adding a rule between each of them.</p>
<p>The <code>column-rule</code> property follows the syntax of the <code>border</code> property. Also, the column rules don&#8217;t take up any space—if they are wider than the column gap, they will (or should) overlap the content.</p>
<p>The column gaps and column rules are all the same within a row.</p>
<p><em>Ignore the colourful blocks in this example for now, I explain those bellow.</em></p>
<h4><code>column-count</code></h4>
<p>On our third example, we will specify how many columns we actually want the element to have:</p>
<pre class="brush: css; title: ; notranslate">#text3 {
	-webkit-column-width: 200px;
	-webkit-column-count: 4;
	-webkit-column-gap: 20px;
	-moz-column-width: 200px;
	-moz-column-count: 4;
	-moz-column-gap: 20px;
	column-width: 200px;
	column-count: 4;
	column-gap: 20px;
	}</pre>
<p>If both <code>column-width</code> and <code>column-count</code> are specified (like in this example), the <code>column-count</code> value will be regarded as the <strong>maximum number of columns</strong>. So if only 3 columns fit in the element, but you&#8217;ve set it to have 4, only 3 will be created.</p>
<p>If you don&#8217;t specify the <em>width</em> of the columns, the <code>column-width</code> will be calculated automatically according to how many columns you have specified.</p>
<h4>Images, etc.</h4>
<p>You can have elements, like images, along the text, and even float them or make them a percentage in width. That percentage will be calculated according to the width of the column box they are in.</p>
<p>To test this theory, I added 3 coloured <code>div</code>s to the second example (<code>#test2</code>), with some inline coding (oh, the horror!). The first, red, <code>div</code> is floated but it has a width of 140%; the second, green, <code>div</code> is not floated and it&#8217;s also 140% wide; and the third, yellow, <code>div</code> is floated, but has 100% width .</p>
<p>According to the <a href="http://www.w3.org/TR/css3-multicol/#overflow-and-multicol-elements" rel="nofollow" >W3C specification</a>, this is what should happen:</p>
<blockquote cite="http://www.w3.org/TR/css3-multicol/#overflow-and-multicol-elements"><p>
Content in the normal flow that extends into column gaps (e.g., long words) is clipped in the middle of the column gap.</p>
<p>Floats that are wider than the column box intrude into neighboring columns.
</p></blockquote>
<p>Correct me if I&#8217;m wrong, but for what I see on these examples, Firefox is overflowing both 140% <code>div</code>s, even if the second one is <em>not</em> floated. Safari doesn&#8217;t do better: it&#8217;s overflowing <em>neither</em> of them.</p>
<h4>More overflowing stuff</h4>
<p>As a final example, I&#8217;m creating a div with a smaller width and a set height. I&#8217;m making the overflow visible, and see what happens…</p>
<pre class="brush: css; title: ; notranslate">#text4 {
	height: 200px;
	width: 500px;
	overflow: visible;
	border: 2px solid red;
	-webkit-column-width: 200px;
	-webkit-column-gap: 20px;
	-moz-column-width: 200px;
	-moz-column-gap: 20px;
	column-width: 200px;
	column-gap: 20px;
	}</pre>
<p><a href="http://www.w3.org/TR/css3-multicol/#overflow-outside-multicol-elements" rel="nofollow" >According to the specs</a>, this is what should happen:</p>
<blockquote cite="http://www.w3.org/TR/css3-multicol/#overflow-outside-multicol-elements"><p>A multi-column element can have more columns than it has room for due to:</p>
<ul>
<li>Constrained column height. […]</li>
</ul>
<p>In continuous media, the columns that do not fit within the multicol element are added in the inline direction. </p></blockquote>
<p>In human language, that means if the content is to be overflown, then it should be to the sides. In this case, Safari seems to be getting it right, while Firefox overflows the content vertically if the height is set via the <code>max-height</code> property, but correctly if via the normal <code>height</code> property. Take a look at the last block on the <a href="http://webdesignernotebook.com/examples/css3-layout.html" rel="nofollow" >example page</a> (with the red border).</p>
<h3>Final words</h3>
<p>And that&#8217;s it! I just wanted to remember you of this wonderful CSS3 feature that can make our lives a lot easier—and that degrades quite nicely for browsers that don&#8217;t support it.</p>
<p>I keep looking for examples of the multi-column layout in the wild, but I don&#8217;t think a lot of people are using it now. For what it&#8217;s worth, I&#8217;m using it on my personal site, <a href="http://yaili.com" rel="nofollow" >yaili.com</a>, and it&#8217;s also in use on the <a href="http://tweetcc.com/" rel="nofollow" >tweetCC</a> website.</p>
<p>Do you know of any more websites using it?</p>
<p><em>This article has been <a href="http://www.fatcow.com/edu/remembering-the-css3-be/" rel="nofollow" >translated to Belorussian</a> by Amanda Lynn.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/remembering-the-css3-multi-column-layout-module/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>How to use Modernizr</title>
		<link>http://webdesignernotebook.com/css/how-to-use-modernizr/</link>
		<comments>http://webdesignernotebook.com/css/how-to-use-modernizr/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 08:50:47 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=976</guid>
		<description><![CDATA[There is a tool that came to make our lives as progressive web designers a bit easier: Modernizr. In this short tutorial, learn how to apply this handy script to maximum effect on your sites. An overview Although CSS3’s use has been increasing among web designers, browser support for some of its features is still [...]]]></description>
			<content:encoded><![CDATA[<p>There is a tool that came to make our lives as progressive web designers a bit easier: Modernizr. In this short tutorial, learn how to apply this handy script to maximum effect on your sites.</p>
<p><span id="more-976"></span></p>
<h3>An overview</h3>
<p>Although CSS3’s use has been increasing among web designers, browser support for some of its features is still inexistent.</p>
<p>Lately, I’ve been using Modernizr more and more to cater for those <strong>browsers that don’t support specific CSS3 properties</strong>—for example, <a href="http://yaili.com" rel="nofollow" >on my site</a>—, and it makes the development much easier because I know I’m providing these lesser browsers with an alternative experience, rather than just ignoring them.</p>
<p>Bear in mind (and this is even splashed on Modernizr’s front page), that Modernizr <strong>doesn’t actually magically enable</strong> these properties for browsers that don’t support them. It just tells the page whether that feature is supported on the browser the visitor is using or not.</p>
<h3>How it works</h3>
<p>To install Modernizr, download the file from <a href="http://www.modernizr.com/" rel="nofollow" >this page</a>. Then, on your site’s head tag, add a link to the file. For example:</p>
<pre class="brush: xml; title: ; notranslate">&lt;script src=&quot;js/modernizr-1.0.min.js&quot;&gt;&lt;/script&gt;</pre>
<p>The second step is to include on your html tag a class of “<code>no-js</code>”:</p>
<pre class="brush: xml; title: ; notranslate">&lt;html class=&quot;no-js&quot;&gt;</pre>
<p><strong>Why add this tag?</strong><br />
Because that will be the default state of the page. If JavaScript (<code>js</code>) isn’t on, then Modernizr won’t work at all (and probably other features of your site won’t work either&#8230;), so it’s good that we have a <strong>fallback</strong> for that case.</p>
<p>If JavaScript is indeed enabled, once that page is loaded on the browser, that class will be replaced dynamically and it may look something like this:</p>
<pre class="brush: xml; title: ; notranslate">&lt;html class=&quot;js canvas canvastext geolocation rgba hsla no-multiplebgs borderimage borderradius boxshadow opacity no-cssanimations csscolumns no-cssgradients no-cssreflections csstransforms no-csstransforms3d no-csstransitions  video audio cufon-active fontface cufon-ready&quot;&gt;</pre>
<p><strong>What does this mean?</strong>  Let’s take a look, shall we?</p>
<p>In this case, I opened the page on Firefox 3.5. This browser (sadly) doesn’t support multiple backgrounds, CSS gradients or CSS transforms, therefore, Modernizr outputs &#8220;<code>no-multipebgs</code>&#8220;, &#8220;<code>no-cssgradients</code>&#8221; and &#8220;<code>no-csstransforms</code>&#8220;. On the other hand, it does support <code>canvas</code> and <code>border-radius</code>, which explains &#8220;<code>canvas</code>&#8221; and &#8220;<code>borderradius</code>&#8220;. Etc.</p>
<h3>How to use this (precious) information?</h3>
<p>So what can you actually do with this? How does that help you in any way?, you might ask.</p>
<p>Let’s look at an example:</p>
<h4>Multiple backgrounds</h4>
<p>Your site’s background has been carefully built and you’re using the multiple background technique to make it simpler (and faster!) to code. Your CSS may look like this:</p>
<pre class="brush: css; title: ; notranslate">#nice {
	background: url(background-one.png) top left repeat-x,
	url(background-two.png) bottom left repeat-x;
}</pre>
<p>And a nice browser will render this:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2009/11/modernizr-safari.jpg" alt="modernizr-safari" title="modernizr-safari" width="241" height="342" class="alignnone size-full wp-image-1034" /></p>
<p>Using Modernizr, your CSS will look instead like this:</p>
<pre class="brush: css; title: ; notranslate">#nice {
	background: url(background-one.png) top left repeat-x;
}
.multiplebgs #nice {
	background: url(background-one.png) top left repeat-x,
	url(background-two.png) bottom left repeat-x;
}</pre>
<p>This is what your visitors will get, depending on which browser they have:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2009/11/modernizr-safari.jpg" alt="modernizr-safari" title="modernizr-safari" width="241" height="342" class="alignnone size-full wp-image-1034" /> <img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2009/11/modernizr-opera.jpg" alt="modernizr-opera" title="modernizr-opera" width="241" height="342" class="alignnone size-full wp-image-1033" /></p>
<p>This is a very simplified use of Modernizr, but hopefully it&#8217;s enough to show you what you can do with it.</p>
<h3>HTML5</h3>
<p>Modernizr also allows you to <strong>use the new HTML5 elements</strong>—<code>header</code>, <code>hgroup</code>, <code>section</code>, <code>footer</code>, <code>video</code>, etc.—and style them.</p>
<p>This doesn’t mean that some of these elements will start working on Internet Explorer, but that you can <strong>style</strong> them and that IE will understand them and not ignore them.</p>
<h3>JavaScript</h3>
<p>You can also detect features using Modernizr in your JavaScript, using this syntax:</p>
<pre class="brush: jscript; title: ; notranslate">if (Modernizr.geolocation) {
}</pre>
<h3>Conclusion</h3>
<p>I hope that I managed to explain the <strong>usefulness</strong> of Modernizr. While we can’t rely on the fact that browsers support the full spectrum of features we want to use, this is the best tool out there to provide for both worlds.</p>
<p><strong>Do you use Modernizr too? How?</strong> If not, how do you deal with some browsers not supporting some features (assuming you <em>are</em> using the latest CSS3 techniques)?</p>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/how-to-use-modernizr/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
	</channel>
</rss>

