<?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; HTML</title>
	<atom:link href="http://webdesignernotebook.com/category/html/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>Mon, 06 Sep 2010 19:28:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<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>3</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;">&lt;p&gt;&lt;/p&gt;</pre>
<p>Or an empty table cell:</p>
<pre class="brush: xml;">&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;">&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;">&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;">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>15</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;">&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;">&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;">&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;">#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;">#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;">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>14</slash:comments>
		</item>
		<item>
		<title>Belgian Beer Types, or How to Style a Definition List the CSS3 Way</title>
		<link>http://webdesignernotebook.com/css/how-to-style-a-definition-list-css3/</link>
		<comments>http://webdesignernotebook.com/css/how-to-style-a-definition-list-css3/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 08:30:47 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=779</guid>
		<description><![CDATA[Definition lists are an often forgotten HTML element, but they can be used in a wide variety of ways, and are actually the most semantically accurate element in many cases. So let&#8217;s see how we can mix up beer, HTML and CSS3, while explaining the purpose of the definition list element. When to use a [...]]]></description>
			<content:encoded><![CDATA[<p>Definition lists are an often forgotten HTML element, but they can be used in a wide variety of ways, and are actually the most semantically accurate element in many cases. So let&#8217;s see how we can mix up beer, HTML and CSS3, while explaining the purpose of the definition list element.</p>
<p><span id="more-779"></span></p>
<h3>When to use a DL</h3>
<p>First, what has the W3 to say about this?</p>
<blockquote><p>
Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description.
</p></blockquote>
<p>That means <strong>we can use them whenever we have something that needs a description</strong>. For example: a list of Belgian beer types, a list of services provided by a company, a list of the persons in a team, etc. Pretty straightforward: instead of using a normal list (<code>ul</code>) with headings and paragraphs in between, we can use an element which already has tags for our definition terms and descriptions.</p>
<h3>The anatomy of a DL</h3>
<p>A definition list is made up by 3 different tags: the opening <code>dl</code> tag; the definition term tag (<code>dt</code>); and the definition description tag (<code>dd</code>). That would look like this:</p>
<pre>&lt;dl&gt;
	&lt;dt&gt;Term goes here...&lt;/dt&gt;
	&lt;dd&gt;Description goes here...&lt;/dd&gt;
&lt;/dl&gt;</pre>
<p>Still easy, right?</p>
<p>To mix things up a bit, we can have more than one term, to more than one definition. For example, a word in a dictionary can have two correct ways of spelling and more than one definition.</p>
<h3>Beer o&#8217;clock</h3>
<p>Now we are going to style a definition list of Belgian beer types (which I recently tried and loved!).</p>
<p>First, some HTML:</p>
<pre>&lt;div id="beers"&gt;

	&lt;h1&gt;A Definition List: Belgian Beer Types&lt;/h1&gt;

	&lt;dl&gt;

		&lt;dt&gt;Amber ales&lt;/dt&gt;
		&lt;dd&gt;These are beers similar to the traditional pale ales of England, although somewhat less bitterly hopped. A notable example is the 5% abv De Koninck brand, with its distinctive spherical glasses (called 'bollekes').&lt;/dd&gt;

		&lt;dt&gt;Blonde or golden ale&lt;/dt&gt;
		&lt;dd&gt;These are a light variation on pale ale, often made with pilsener malt. Some beer writers regard blonde and golden ales as distinct styles, while others do not.&lt;/dd&gt;

		&lt;dt&gt;Brown Ale&lt;/dt&gt;
		&lt;dd&gt;Regular bruin or brune beers such as Grottenbier are darker than amber ales, less sour than Flemish brown ale, and less strong than dubbel.&lt;/dd&gt;

		&lt;dt&gt;Dubbel&lt;/dt&gt;
		&lt;dd&gt;Dubbel has a characteristic brown color. It is one of the classic Abbey/Trappist types, having been developed in the 19th century at the Trappist monastery in Westmalle.&lt;/dd&gt;

		&lt;dt&gt;Enkel&lt;/dt&gt;
		&lt;dd&gt;This beer is the basic recipe for what was traditionally a range of three beers of increasing alcohol content.&lt;/dd&gt;

		&lt;dt&gt;Flemish Red&lt;/dt&gt;
		&lt;dd&gt;Typified by Rodenbach, the eponymous brand that started this type over a century ago, this beer's distinguishing features from a technical viewpoint are a specially roasted malt, fermentation by a mixture of several 'ordinary' top-fermenting yeasts and a lactobacillus culture and maturation in oak.&lt;/dd&gt;

	&lt;/dl&gt;

&lt;/div&gt;</pre>
<p>So, we&#8217;re wrapping our content in a nice container (<code>div</code>), then a little descriptive title (<code>h1</code>) for our page and finally our definition list, with the beer types as definition terms (<code>dt</code>) and each description as a <code>dd</code>.</p>
<h3>CSS 3 magic</h3>
<p><em>I should warn you: this WILL NOT work on IE6. The page will still have its colours and main formatting, but none of the sweet CSS 3 styling is going to be seen. When you&#8217;re driving an inferior car, you don&#8217;t expect it to go as fast as a Ferrari, do you? You&#8217;ll still get there, but with less, or no style.</em></p>
<p>First we&#8217;ll <strong>add some defaults</strong> to our stylesheet (you should be using a proper reset on your stylesheets, but let&#8217;s make things simpler here), and we&#8217;ll also <strong>style the container</strong> <code>div</code>:</p>
<pre>body {
	margin: 0;
	padding: 20px;
	text-align: center;
	background: #fff;
	}

h1,
dl, dt, dd,
p,
a {
	margin: 0;
	padding: 0;
	}

#beers {
	width: 500px;
	padding: 20px;
	margin: auto;
	background: #eeebe3;
	border: 5px solid #5a523d;
	text-align: left;
	}</pre>
<p>Let me know in the comments if you need explaining for this part&#8230;</p>
<p>Now onto the type bit:</p>
<pre>h1 {
	font: 32px "Delicious-Bold", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif;
	text-align: center;
	color: #3d3111;
	margin-bottom: 20px;
	}

p {
	font: 16px/1.3 "Delicious-Bold", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif;
	}</pre>
<p>And this is where the fun begins: <strong>we are going to use the <code>@font-face</code> attribute</strong> to call the Delicious typeface. Remember that this typeface is available for <code>@font-face</code> embedding (you can see a list of available fonts in the Useful links section of this post), but not all are.</p>
<p>We&#8217;ll add this bit to the beginning of our stylesheet, before the <code>body</code> style details, so that all the <code>@font-face</code> info is easily seen. We then only have to call the font we want to use by the <code>font-family</code> value we give it here (see code above):</p>
<pre>@font-face{
	font-family: 'Delicious';
	src: url('Delicious-Roman.otf') format('opentype');
	}

@font-face{
	font-family: 'Delicious-Bold';
	src: url('Delicious-Bold.otf') format('opentype');
	}

@font-face{
	font-family: 'Delicious-Heavy';
	src: url('Delicious-Heavy.otf') format('opentype');
	}</pre>
<p>And now, our definition list:</p>
<pre>dl {
	margin-bottom: 20px;
	}

	dt {
		font: 22px "Delicious-Heavy", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif;
		text-shadow: rgba(255,255,255,.8) 2px 2px 0;
		text-align: center;
		color: #822020;
		margin-bottom: 5px;
		}</pre>
<p>OK, lots to talk about here!</p>
<p>First we add a <strong>bottom margin</strong> to the <code>dl</code>, so that there is some space between it and the paragraph that comes next.</p>
<p>Then we define the <strong>font size and font family</strong> for our <code>dt</code> (and <code>dd</code>, see bellow, after the image). </p>
<p>We also add a <strong>nice little shadow</strong> to both of them. For that, we are using RGBa colours, which allow us to add, besides the r,g and b values, a transparency value between 1 (fully opaque) and 0 (fully transparent). The values that come after the <code>rgba</code> are the horizontal and vertical offset of the shadow, and then the amount of blur (in this case, zero).</p>
<p>Next, we add some <strong>white space around our terms</strong>, and give it a reddish <strong>colour</strong>.</p>
<p>Finally, we are going to add a <strong>decorative border</strong> to each of our descriptions, but we&#8217;re not using a background because each description has a different length: we need something more flexible, and we need to show off our CSS3 skills too. So we are going to use the <code>border-image</code> property.</p>
<p>The <code>border-image</code> property allows us to use an image and specify how much of its borders we want to apply to the borders of our element.</p>
<p>We need to specify the width of the border of the element, in this case it will be 20px. After that, we will specify the image we&#8217;re using for our border, which in our case is this one:</p>
<p><img src="http://webdesignernotebook.com/wp_livesite/wp-content/uploads/2009/07/bubble.png" alt="bubble" title="bubble" width="328" height="231" class="alignnone size-full wp-image-786" /></p>
<p>(Do you see a nasty light blue background around this image? You&#8217;re using IE6!)</p>
<p>We will also need to say how much of the image we are using for our borders: 20; and how it should behave: will it stretch to the size of the element, or will it be repeated? In our case, we want it to stretch. And this is what we get:</p>
<pre>dd {
	font: 16px "Delicious", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif;
	text-shadow: rgba(255,255,255,.5) 1px 1px 0;
	padding: 10px;
	border-width: 20px;
	-moz-border-image: url(bubble.png) 20 stretch;
	-webkit-border-image: url(bubble.png) 20 stretch;
	-khtml-border-image: url(bubble.png) 20 stretch;
	border-image: url(bubble.png) 20 stretch;
	margin-bottom: 30px;
	}</pre>
<p>We are using the <strong>vendor specific properties</strong> so that the <code>border-image</code> is understood by all of them. Someday, we will only need the last line of this bit of code, instead of 4 lines.</p>
<h3>Browser support</h3>
<p>I&#8217;ve said that this is not going to work on IE6. What I didn&#8217;t say, was that it doesn&#8217;t work on IE8 or 7 either. Oh, and Opera will ignore the border-image property (at least on my copy of Opera 9.64, but correct me if I&#8217;m wrong).</p>
<p>For Internet Explorer to understand the <code>@font-face</code> attribute, you will need to use the <abbr title="Embedded OpenType">EOT</abbr> font format, so you will have to duplicate the 3 <code>@font-face</code> attributes and use the .eot files for that.</p>
<h3>Conclusion</h3>
<p>Hopefully this made it a bit easier to understand how definition lists can be really useful, and how CSS 3 makes styling rich designs so much easier.</p>
<p>You can download the example files bellow, and you can <a href="http://www.josbuivenga.demon.nl/delicious.html" rel="nofollow" >grab the Delicious font from here</a>.</p>
<p><a href="/examples/css-belgium-beers-dl/css-belgium-beers-dl.html" rel="nofollow"  class="example">View example</a> <a href="http://webdesignernotebook.com/downloads/8" class="files" title="CSS Belgian Beers Definition List | 5.82 kB">Download source files</a></p>
<p>Was this post too short? Did you need more details to understand what just happened? Let me know in the comments.</p>
<h3>Useful links</h3>
<ul>
<li><a href="http://webfonts.info/wiki/index.php?title=Fonts_available_for_%40font-face_embedding" rel="nofollow" >Fonts available for @font-face embedding</a></li>
<li><a href="http://www.w3.org/TR/html401/struct/lists.html#h-10.3" rel="nofollow" >Lists in HTML documents</a></li>
<li><a href="http://www.smashingmagazine.com/2009/06/15/take-your-design-to-the-next-level-with-css3/" rel="nofollow" >Take Your Design To The Next Level With CSS3</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/how-to-style-a-definition-list-css3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Styling a Poem with Advanced CSS Selectors</title>
		<link>http://webdesignernotebook.com/css/styling-a-poem-with-advanced-css-selectors/</link>
		<comments>http://webdesignernotebook.com/css/styling-a-poem-with-advanced-css-selectors/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 09:47:20 +0000</pubDate>
		<dc:creator>Inayaili León</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=383</guid>
		<description><![CDATA[CSS3 selectors offer endless possibilities of targeting specific HTML elements without the need of extra markup (which was already possible with previous versions of CSS). This time, I&#8217;m going to style the popular nursery rhyme &#8220;Twinkle Twinkle Little Star&#8221; using advanced CSS selectors, all in less than 5 minutes! Coding a poem There isn&#8217;t a [...]]]></description>
			<content:encoded><![CDATA[<p>CSS3 selectors offer endless possibilities of targeting specific HTML elements without the need of extra markup (which was already possible with previous versions of CSS). This time, I&#8217;m going to style the popular nursery rhyme &#8220;Twinkle Twinkle Little Star&#8221; using advanced CSS selectors, all in less than 5 minutes!</p>
<p><span id="more-383"></span></p>
<h3>Coding a poem</h3>
<p>There isn&#8217;t a consensus on how a poem should be marked up using HTML: most people believe that each <a href="http://en.wikipedia.org/wiki/Stanza" rel="nofollow" >stanza</a> should be a paragraph (<code>p</code>) and each line separated by a line break (<code>br</code>). There have been some mentions to a future <a href="http://blog.signified.com.au/a-poem-element-for-html5/" rel="nofollow" >poem tag on HTML5</a>, but it&#8217;s very unlikely to happen! :)</p>
<h3>The markup</h3>
<p>There are 3 main elements in our markup: 1) the title; 2) the sub-title, with the author information; and 3) the poem itself. This is the very simple markup we are going to use for this example:</p>
<pre>&lt;h1&gt;Twinkle Twinkle Little Star&lt;/h1&gt;

&lt;h2&gt;by Jane Taylor, 1806&lt;/h2&gt;

&lt;p&gt;Twinkle, twinkle, little star,&lt;br /&gt;
How I wonder what you are!&lt;br /&gt;
Up above the world so high,&lt;br /&gt;
Like a diamond in the sky!&lt;/p&gt;

&lt;p&gt;When the blazing sun is gone,&lt;br /&gt;
When he nothing shines upon,&lt;br /&gt;
Then you show your little light,&lt;br /&gt;
Twinkle, twinkle, all the night.&lt;/p&gt;

&lt;p&gt;Then the traveller in the dark,&lt;br /&gt;
Thanks you for your tiny spark,&lt;br /&gt;
He could not see which way to go,&lt;br /&gt;
If you did not twinkle so.&lt;/p&gt;

&lt;p&gt;In the dark blue sky you keep,&lt;br /&gt;
And often through my curtains peep,&lt;br /&gt;
For you never shut your eye,&lt;br /&gt;
Till the sun is in the sky.&lt;/p&gt;

&lt;p&gt;As your bright and tiny spark,&lt;br /&gt;
Lights the traveller in the dark,&amp;mdash;&lt;br /&gt;
Though I know not what you are,&lt;br /&gt;
Twinkle, twinkle, little star.&lt;/p&gt;</pre>
<h3>Styling the headings</h3>
<p>Before starting to style the elements on the page, lets just add some basic resets and defaults:</p>
<pre>body {
	background: #FFF;
	color: #111;
	font: 14px Baskerville, "Palatino Linotype", "Times New Roman", Times, serif;
	text-align: center;
	}

	div, h1, h2, p {
		margin: 0;
		padding: 0;
		}</pre>
<p>We will also wrap our poem inside a <code>div</code>, to center the content nicely on the page:</p>
<pre>#poem {
	margin: auto;
	padding: 20px 0;
	text-align: left;
	width: 390px;
	}</pre>
<p>Next, we will center our headings and override the default bolds that headings have:</p>
<pre>h1, h2 {
	font-weight: normal;
	text-align: center;
	}</pre>
<p>Now, we will set the font size of the main heading, the <code>h1</code> tag;  add a nice margin to the bottom; and a small <code>line-height</code> (because the font is so large, this way if our heading is very long, the lines won&#8217;t be too far apart from each other):</p>
<pre>h1 {
	font-size: 34px;
	line-height: 1.2;
	margin-bottom: 10px;
	}</pre>
<p>For the <code>h2</code> heading, with the author and date details, we will use a different, lighter colour; set a smaller <code>font-size</code>; make it italic, for that extra special touch; and also add a bottom margin:</p>
<pre>h2 {
	color: #666;
	font-size: 18px;
	font-style: italic;
	margin-bottom: 30px;
	}</pre>
<h3>The poem</h3>
<p>For the body of the poem itself, we will add a larger <code>line-height</code>, so that each line has some white space around it and is easier to read. We will also add a bottom margin to each paragraph, to visually separate each stanza:</p>
<pre>p {
	line-height: 1.5;
	margin-bottom: 15px;
	}</pre>
<h3>The magical selectors</h3>
<p>And now we can start having fun! First, lets add a decorative element before and after the author details. This will be done using the <code>:before</code> and <code>:after</code> pseudo-elements in conjunction with the <code>content</code> CSS property:</p>
<pre>h2:before {
	content: '— ';
	}

h2:after {
	content: ' —';
	}</pre>
<p>Now, let&#8217;s make the first letter of the poem really big &mdash; a drop cap. For that, we will be using the adjacent sibling selector (<code>+</code>) and the <code>:first-letter</code> pseudo-element. The adjacent sibling selector lets us target selectors that directly follow each other and are within the same parent element (for example, inside the same <code>div</code>). We will target the first letter of all paragraphs that follow an <code>h2</code> tag, which, in our example, is only the first paragraph of the poem:</p>
<pre>#poem h2 + p:first-letter {
	float: left;
	font-size: 38px;
	line-height: 1;
	margin: 2px 5px 0 0;
	}</pre>
<p>So we floated the first letter to the left, so that the rest of the text wraps around it; used a bigger font size; reduced the <code>line-height</code>, so that the following lines aren&#8217;t pushed down; and slightly repositioned the letter within the paragraph with some margin settings.</p>
<p>Next, we&#8217;ll make the first line of each paragraph display the letters in small-caps, and, to make it easier to read, add some extra space between each letter:</p>
<pre>#poem p:first-line {
	font-variant: small-caps;
	letter-spacing: 1px;
	}</pre>
<p>To wrap things up, we&#8217;ll just add an extra bottom margin to our last paragraph, so that the poem is well separated from whatever comes next. For that, we will use the <code>:last-child</code> pseudo-element, which lets us target an element that is the last element of its parent:</p>
<pre>#poem p:last-child {
	margin-bottom: 30px;
	padding-bottom: 30px;
	}</pre>
<p>And we&#8217;re done!</p>
<h3>Some notes on browser support</h3>
<p>Don&#8217;t expect this to work equally on every major browser. The latest versions of Safari, Firefox and Opera do support all the selectors. But&#8230; Internet Explorer 8 doesn&#8217;t support the <code>:last-child</code> pseudo-class; Internet Explorer 7 doesn&#8217;t support <code>:last-child</code> or the <code>:before</code> and <code>:after</code> pseudo-elements; and IE6 doesn&#8217;t support the <code>:first-letter</code> pseudo-element, on top of that.</p>
<h3>Conclusion</h3>
<p>This is a very basic tutorial on how CSS advanced selectors can be used in our stylesheets to address specific HTML elements without having to use extra classes, IDs or bloated markup. It will not work on older browsers, like Internet Explorer 6, which will render only the most basic CSS properties (with few exceptions), but that won&#8217;t make the text unreadable &mdash; it will simply add a new layer of detail to modern browsers, as if it was a little present for people who are up-to-date.</p>
<p><a href="/examples/twinkle-twinkle.html" rel="nofollow"  class="example">View example</a> <a href="http://webdesignernotebook.com/downloads/7" class="files" title="Twinkle Twinkle Little Star | 2.09 kB">Download source files</a></p>
<h3>Further reading</h3>
<ul>
<li><a href="http://www.w3.org/TR/css3-selectors/" rel="nofollow" >Selectors Level 3 &mdash; W3C Working Draft 10 March 2009</a></li>
<li><a href="http://reference.sitepoint.com/css/selectorref" rel="nofollow" >CSS Selectors</a></li>
<li><a href="http://kimblim.dk/css-tests/selectors/" rel="nofollow" >CSS selectors and pseudo selectors browser compatibility</a></li>
<li><a href="http://www.smashingmagazine.com/2009/06/15/take-your-design-to-the-next-level-with-css3/" rel="nofollow" >Take Your Design To The Next Level With CSS3</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/styling-a-poem-with-advanced-css-selectors/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Adding Style With CSS: Beautiful Text</title>
		<link>http://webdesignernotebook.com/css/beautiful-text/</link>
		<comments>http://webdesignernotebook.com/css/beautiful-text/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 21:57:10 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/?p=171</guid>
		<description><![CDATA[This may seem like a no-brainer, but adding style to your HTML is not just about adding pretty backgrounds and borders. The foundation of a good looking site has to be, with a couple other things, the way text is set. So let&#8217;s see how, with just a few lines of very simple CSS, we [...]]]></description>
			<content:encoded><![CDATA[<p>This may seem like a no-brainer, but adding style to your HTML is not just about adding pretty backgrounds and borders. The foundation of a good looking site has to be, with a couple other things, the way text is set. So let&#8217;s see how, with just a few lines of very simple CSS, we can quickly make our type a bit more beautiful and easier to read.</p>
<p><span id="more-171"></span></p>
<h3>The markup</h3>
<p>Before adding style to our text, we have to make sure we mark it up correctly.</p>
<p>For the main title of the page we should use the <code>h1</code> tag (this has been <a href="http://www.andybudd.com/archives/2004/03/quick_quiz_h1s_and_logos/" rel="nofollow" >a</a> <a href="http://www.h1debate.com/" rel="nofollow" >long</a> <a href="http://www.topicobserver.com/blog/web-development/2008/semantics-in-html-whats-in-a-heading/" rel="nofollow" >running</a> <a href="http://abovetheinternet.org/2009/02/04/the-h1-debate/" rel="nofollow" >discussion</a> within web developers, some prefer to use this tag for the page’s logo while others for the title of the page).</p>
<p>The subheadings should be tagged as <code>h2</code>, <code>h3</code>, etc., until <code>h6</code>, according to its importance and hierarchy within the content.</p>
<p>Paragraphs of text should be marked up as <code>p</code>; lists as either <code>ol</code> or <code>ul</code>, depending on whether the information is ordered or unordered; and long quotations should be marked up nicely as <code>blockquote</code> (with a <a href="https://developer.mozilla.org/En/HTML/Block-level_elements" rel="nofollow" >block level element</a> inside it, like a <code>p</code>, <code>div</code>, <code>ul</code> or <code>ol</code>).</p>
<p>You can see the source code on the <a href="/examples/css-text.html" rel="nofollow" >example page</a> for more detail.</p>
<h3>General styles</h3>
<p>First we&#8217;ll start by defining some general styles for the page and the elements. I&#8217;m not going to apply a complete CSS reset, because it would be overdoing it for this simple example:</p>
<pre>
body {
	margin:0;
	padding:0;
	font:62.5% "Helvetica Neue", Helvetica, Arial, sans-serif;
	color:#000;
	text-align:center;
	}

div,
h1, h2, h3, h4, h5, h6,
p,
ul, ol, li,
blockquote {
	margin:0;
	padding:0;
	}
</pre>
<p>So, we:</p>
<ol>
<li>Reset the margins and paddings of the body and the other elements to zero</li>
<li>Set the overall size of the font to 62.5%&mdash;this is a little trick that will make our lives easier. When we set the font size of the page to 62.5%, we can convert the em measures we use to pixels just by multiplying them by 10 (for example, 1.2em equals 12px)</li>
<li>Set the colour of the text to black</li>
<li>Centre align the text of the page: this is only needed for some older browsers to position our container <code>div</code> to the centre</li>
</ol>
<p>Now we&#8217;ll quickly style the container <code>div</code>:</p>
<pre>
div.text {
	width:50em;
	padding:2em 0;
	margin:auto;
	text-align:left;
	}
</pre>
<p>We made it long enough so that the lines of text are comfortable to read, but not too wide; added some padding to the top and bottom; aligned the container to the centre of the page (<code>margin:auto</code>) and made the text inside the container left aligned (remember we had previously set the text of the <code>body</code> element to be aligned to the centre).</p>
<h3>Headings</h3>
<p>On the web, it&#8217;s a generally accepted rule (but not set in stone) that it&#8217;s easier to read text when the headings are set in a serif font while the rest of the text is set in a non-serif font.</p>
<p>We&#8217;ll follow that rule here and set the headings to Georgia (a common font to most operating systems). We&#8217;ll also have a smaller <code>line-height</code> for the headings than for the rest of the text:</p>
<pre>
h1, h2, h3, h4, h5, h6 {
	font-family:Georgia, "Times New Roman", Times, serif;
	line-height:1.2;
	}
</pre>
<p>Now let&#8217;s define the font size of each of the headings we are using on the page (it&#8217;s good practice to style all the possible headings, even if you don&#8217;t use them on your page, it may come in hand later, but let&#8217;s keep this tutorial short):</p>
<pre>
h1 {
	font-size:3.4em;
	margin-bottom:.8em;
	}

h2 {
	font-size:2.4em;
	padding-bottom:.2em;
	border-bottom:1px solid #333;
	margin-top:1em;
	margin-bottom:.7em;
	}

h3 {
	font-size:1.8em;
	margin-bottom:.7em;
	}
</pre>
<p>We also added some margin to the bottom of the headings, so that there is some white space between them and the text that follows.</p>
<p>To add some eye-candy and pace to our page, I added a thin border (and padding) to the bottom of the <code>h2</code> headings.</p>
<h3>Paragraphs</h3>
<pre>
p {
	font-size:1.3em;
	line-height:1.5;
	margin-bottom:1.3em;
	}
</pre>
<p>The paragraphs need a smaller font size than the headings, and also need some white space around them, hence the bottom margin and a bigger line height: this makes the text easier to read. Make sure you don&#8217;t use a <code>line-height</code> so big that keeps the text from being a concise block and the lines too spread apart.</p>
<h3>Lists</h3>
<p>Like for the headings and paragraphs, the lists (whether ordered or unordered) should also have proper white space around them. So we&#8217;ll make sure there is always a bottom margin and a small left indentation (left margin), and we&#8217;ll also make the font the same size of the paragraphs:</p>
<pre>
ul, ol {
	font-size:1.3em;
	margin:0 0 1.3em 2em;
	}

	li {
		margin-bottom:.4em;
		}
</pre>
<p>For each <code>li</code>, I&#8217;m also adding a small <code>margin-bottom</code>, so that there is a nice space between each of them and they&#8217;re not all cramped on top of each other.<br />
For this example, I&#8217;m keeping the default list styles (<code>decimal</code>, for ordered; and <code>disc</code>, for unordered): they look fine in most of the cases.</p>
<h3>Quotes</h3>
<p>A common element used in texts is the <code>blockquote</code>. This is the right element to be used when making a long quotation.</p>
<p>Since we&#8217;re using someone else&#8217;s words, it&#8217;s a nice touch to use an italic font in this case. Because Helvetica&#8217;s italic isn&#8217;t as nice, we&#8217;ll use Georgia for <code>blockquote</code>s. We&#8217;ll also add some margin and padding, and apply a nice light grey border to the left of the quotes, so that they are easy to spot while browsing the page.</p>
<pre>
blockquote {
	padding-left:1em;
	border-left:3px solid #999;
	margin:2.5em 2em;
	}

	blockquote p {
		font:italic 1.2em/1.6 Georgia, "Times New Roman", Times, serif;
		}
</pre>
<p>You can find more information on how to style the <code>blockquote</code> element in the Resources &#038; Further Reading links.</p>
<h3>Conclusion</h3>
<p>It&#8217;s easy to style your HTML text with CSS and to make it a bit more pleasant to read. You just have to make sure to follow some simple rules:</p>
<ul>
<li>Use the correct markup: headings, paragraphs, lists, etc.</li>
<li>Use margins and padding to add enough white space around each element</li>
<li>Don&#8217;t forget to add appropriate line heights, for ease of read</li>
</ul>
<p>There&#8217;s a lot more you can do with your text with CSS: the possibilities are endless. I hope that after reading this quick tutorial you have a better idea of how to do it. The References and Further Reading links are a great place to start if you want to improve your type with CSS!</p>
<p>You can download the example files here:</p>
<p><a href="/examples/css-text.html" rel="nofollow" class="example" >View example</a> <a href="http://webdesignernotebook.com/downloads/1" class="files" title="CSS Text | 2.61 kB">Download source files</a></p>
<h3>References</h3>
<ul>
<li><a href="http://www.w3.org/TR/html401/struct/global.html#h-7.5.5" rel="nofollow" >The global structure of an HTML document&mdash;Headings</a></li>
<li><a href="http://www.w3.org/TR/html4/struct/lists.html" rel="nofollow" >Lists in HTML documents</a></li>
<li><a href="http://www.w3schools.com/TAGS/tag_blockquote.asp" rel="nofollow" >HTML blockquote tag</a></li>
</ul>
<h3>Further reading &#038; Tools</h3>
<ul>
<li><a href="http://www.inspirationbit.com/striking-web-sites-with-font-stacks-that-inspire/" rel="nofollow" >Striking Web Sites with Font Stacks that Inspire</a></li>
<li><a href="http://www.3point7designs.com/blog/2008/06/02/10-examples-of-beautiful-css-typography-and-how-they-did-it/" rel="nofollow" >10 Examples of Beautiful CSS Typography and how they did it…</a></li>
<li><a href="http://www.typechart.com/" rel="nofollow" >Typechart</a></li>
<li><a href="http://www.inspirationbit.com/georgia-on-my-mind/" rel="nofollow" >Georgia On My Mind</a></li>
<li><a href="http://www.3point7designs.com/blog/2008/11/04/25-sites-that-use-typography-as-the-only-design-element/" rel="nofollow" >25+ Sites that Use Typography As The Only Design Element</a></li>
<li><a href="http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/" rel="nofollow" >A Killer Collection of Global CSS Reset Styles</a></li>
<li><a href="http://www.htmlsource.co.uk/using-css-and-blockquote/" rel="nofollow" >using CSS and blockquote</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/beautiful-text/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Tidier Internet Explorer Stylesheet</title>
		<link>http://webdesignernotebook.com/css/a-tidier-internet-explorer-stylesheet/</link>
		<comments>http://webdesignernotebook.com/css/a-tidier-internet-explorer-stylesheet/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 10:22:12 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/wp_livesite/?p=40</guid>
		<description><![CDATA[Until recently, I used to separate my IE only stylesheets as ie6.css and ie7.css (and sometimes even ie.css), but lately I’ve been thinking a lot about how inefficient and long winded this process really is. It has made me realize that I could just as easily use IE CSS filters to my advantage, and merge [...]]]></description>
			<content:encoded><![CDATA[<p>Until recently, I used to separate my IE only stylesheets as ie6.css and ie7.css (and sometimes even ie.css), but lately I’ve been thinking a lot about how inefficient and long winded this process really is. It has made me realize that I could just as easily use IE CSS filters to my advantage, and merge these separate .css files into a singular Internet Explorer specific CSS file, which would be much more efficient in the long run.</p>
<p><span id="more-40"></span></p>
<h3>CSS Filters</h3>
<p>There is a list of CSS filters you can use in your stylesheets, but be aware that most of them will make your files invalid, which is why it’s better to use them only within separate IE only stylesheets.</p>
<p>In my case, I use two different filters: one to target IE6 and another for IE7. When I want a rule to affect both, I use no filter, since the HTML conditional comment (see bellow) will target all IE versions from 7 and bellow.</p>
<h4>IE6 and bellow</h4>
<p>Add <code>* html</code> before the CSS rule you want to work on IE6 only (like, for example PNG filters).</p>
<pre>
* html { property:value; }
</pre>
<h4>IE7</h4>
<p>Both IE6 and IE7 can understand a property with an <code>*</code> before it, but IE6 will not interpret it if it&#8217;s preceded with <code>html>body</code>. For example:</p>
<pre>
html>body { *property:value; }
</pre>
<h3>Conditional Comments</h3>
<p>You should use these conditional comments within your HTML files to make sure that only one or more specific versions of IE can read a particular stylesheet. For example:</p>
<pre>
&lt;!--[if IE]>
Internet Explorer
&lt;![endif]-->

&lt;!--[if IE 5]>
Internet Explorer 5
&lt;![endif]-->

&lt;!--[if IE 5.0]>
Internet Explorer 5.0
&lt;![endif]-->

&lt;!--[if IE 5.5]>
Internet Explorer 5.5
&lt;![endif]-->

&lt;!--[if IE 6]>
Internet Explorer 6

&lt;![endif]-->

&lt;!--[if IE 7]>
Internet Explorer 7
&lt;![endif]-->

&lt;!--[if gte IE 5]>
Internet Explorer 5 or greater
&lt;![endif]-->

&lt;!--[if lt IE 6]>
Internet Explorer versions less than 6
&lt;![endif]-->

&lt;!--[if lte IE 5.5]&gt;
Internet Explorer version 5.5 or less
&lt;![endif]--&gt;

&lt;!--[if gt IE 6]&gt;
Internet Explorer greater than version 6
&lt;![endif]--&gt;
</pre>
<p><code>gt</code> stands for greater than, while <code>lt</code> stands for less than. <code>gte</code> stands for greater than or equal, while <code>lte</code> stands for less than or equal to.</p>
<h3>How I do it</h3>
<p>As I mentioned previously, I tend to only use IE6 and 7 specific stylesheets on my websites.  This means that If I were implementing a singular IE stylesheet with IE CSS filters, it would have to use a conditional comment that would allow me to target both these browsers.</p>
<p>Therefore, the most appropriate HTML comment for this kind of sheet would be <code>&lt;!--[if lte IE 7]&gt;</code>. This is acceptable because it targets all versions of IE equal to or below IE7, which is suitable for the most part as I’m not really worried of how the site will look like on any version below IE 6.</p>
<p>So, the final HTML code would look something like this:</p>
<pre>
&lt;!--[if lte IE 7]&gt;
&lt;link rel="stylesheet" type="text/css" href="ie.css" media="screen" /&gt;
&lt;![endif]--&gt;
</pre>
<h3>Conclusion</h3>
<p>Although, truthfully most web designers would like to ignore older versions of Internet Explorer, clients don’t like that idea, and most of the time it’s for a very good reason: there’s still a big percentage of users browsing the web with Internet Explorer, and IE6 in particular: to name but one.</p>
<p>So, as we have discussed, we can make everybody happy, and to have some peace of mind by creating a separate stylesheet and add a couple of properties that will make things a bit prettier for IE users.</p>
<p>If in the future, you don’t need these CSS files anymore (and let’s all hope for it!), you’ll simply have to remove the conditional comments and you’re all set: There’s no need to go through your main stylesheets, that you’ve created for proper browsers and as an extra plus everything will look a bunch cleaner to boot!</p>
<h3>Resources</h3>
<ul>
<li><a href="http://www.quirksmode.org/css/condcom.html" rel="nofollow" >CSS Conditional comments</a></li>
<li><a href="http://www.quirksmode.org/css/csshacks.html" rel="nofollow" >CSS Conditional Hacks</a></li>
</ul>
<h3>Further reading</h3>
<ul>
<li><a href="http://centricle.com/ref/css/filters/" rel="nofollow" >Will the browser apply the rule(s)?</a></li>
<li><a href="http://thingsilearn.wordpress.com/2007/01/31/hello-world/" rel="nofollow" >Internet Explorer 7 CSS filter</a></li>
<li><a href="http://thingsilearn.wordpress.com/2008/06/27/opera-95-css-filter/" rel="nofollow" >Opera 9.5 CSS filter</a></li>
<li><a href="http://snook.ca/archives/html_and_css/targetting_ie7/" rel="nofollow" >Targeting IE7 using CSS</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/a-tidier-internet-explorer-stylesheet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding Style with CSS: A Beautiful Table</title>
		<link>http://webdesignernotebook.com/css/a-beautiful-table/</link>
		<comments>http://webdesignernotebook.com/css/a-beautiful-table/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 00:15:38 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/wp_livesite/?p=30</guid>
		<description><![CDATA[I’ve always enjoyed styling tables. I’m a perfectionist when it comes to it and I just love the process of adding little bits of love and care to completely transform a dull and drab table into something fun, lively and pleasant to look at. This article will go into one of the diverse ways in [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve always enjoyed styling tables. I’m a perfectionist when it comes to it and I just love the process of adding little bits of love and care to completely transform a dull and drab table into something fun, lively and pleasant to look at. This article will go into one of the diverse ways in which I style them and I hope it inspires you to make your own exciting tables.</p>
<p><span id="more-30"></span></p>
<h3>Semantic markup</h3>
<p>Here’s an example of a table that you’ve probably seen many times before. As always, we begin by wrapping up our content in some semantically correct markup. This way the table will make more sense to screen readers, as well as being easier for us to add some of the CSS pixie dust, without having to add unnecessary markup to it.</p>
<pre>
&lt;table summary="Travel times to work by main mode (Autumn 2006)
    - Source: London Travel Report 2007
    http://www.tfl.gov.uk/assets/downloads/corporate/London-Travel-Report-2007-final.pdf"&gt;

	&lt;caption&gt;Travel patterns in London - Travel times to work by main mode (Autumn 2006) - Minutes&lt;/caption&gt;

    &lt;thead&gt;
    	&lt;tr&gt;
            &lt;th scope="col" rowspan="2"&gt;Main mode&lt;/th&gt;

            &lt;th scope="col" colspan="6"&gt;Area of workplace&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
            &lt;&lt;th scope="col"&gt;Central London&lt;/th&gt;

            th scope="col"&gt;Rest of Inner London&lt;/th&gt;
            &lt;th scope="col"&gt;Outer London&lt;/th&gt;
            &lt;th scope="col"&gt;All London&lt;/th&gt;
            &lt;th scope="col"&gt;Rest of Great Britain&lt;/th&gt;

            &lt;th scope="col"&gt;Great Britain&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;

    &lt;tfoot&gt;
    	&lt;tr&gt;

            &lt;th scope="row"&gt;All modes&lt;/th&gt;
            &lt;td&gt;55&lt;/td&gt;
            &lt;td&gt;39&lt;/td&gt;
            &lt;td&gt;27&lt;/td&gt;

            &lt;td&gt;39&lt;/td&gt;
            &lt;td&gt;20&lt;/td&gt;
            &lt;td&gt;23&lt;/td&gt;
        &lt;/tr&gt;

    &lt;/tfoot&gt;

    &lt;tbody&gt;
    	&lt;tr&gt;
    	    &lt;th scope="row"&gt;Car and van&lt;/th&gt;
            &lt;td&gt;48&lt;/td&gt;

            &lt;td&gt;32&lt;/td&gt;
            &lt;td&gt;25&lt;/td&gt;
            &lt;td&gt;29&lt;/td&gt;
            &lt;td&gt;20&lt;/td&gt;

            &lt;td&gt;20&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
            &lt;th scope="row"&gt;Motorbike, moped, scooter&lt;/th&gt;

            &lt;td&gt;36&lt;/td&gt;
            &lt;td&gt;29&lt;/td&gt;
            &lt;td&gt;27&lt;/td&gt;
            &lt;td&gt;31&lt;/td&gt;

            &lt;td&gt;19&lt;/td&gt;
            &lt;td&gt;21&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;

            &lt;th scope="row"&gt;Bicycle&lt;/th&gt;
            &lt;td&gt;33&lt;/td&gt;
            &lt;td&gt;24&lt;/td&gt;
            &lt;td&gt;20&lt;/td&gt;

            &lt;td&gt;25&lt;/td&gt;
            &lt;td&gt;15&lt;/td&gt;
            &lt;td&gt;17&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
            &lt;th scope="row"&gt;Bus and coach&lt;/th&gt;
            &lt;td&gt;47&lt;/td&gt;
            &lt;td&gt;39&lt;/td&gt;

            &lt;td&gt;36&lt;/td&gt;
            &lt;td&gt;40&lt;/td&gt;
            &lt;td&gt;33&lt;/td&gt;
            &lt;td&gt;34&lt;/td&gt;

        &lt;/tr&gt;

        &lt;tr&gt;
            &lt;th scope="row"&gt;National Rail&lt;/th&gt;
            &lt;td&gt;69&lt;/td&gt;

            &lt;td&gt;66&lt;/td&gt;
            &lt;td&gt;43&lt;/td&gt;
            &lt;td&gt;66&lt;/td&gt;
            &lt;td&gt;47&lt;/td&gt;

            &lt;td&gt;58&lt;/td&gt;&gt;
        &lt;/tr&gt;

        &lt;tr
            &lt;th scope="row"&gt;Underground, tram, light rail&lt;/th&gt;
            &lt;td&gt;49&lt;/td&gt;

            &lt;td&gt;45&lt;/td&gt;
            &lt;td&gt;37&lt;/td&gt;
            &lt;td&gt;47&lt;/td&gt;
            &lt;td&gt;42&lt;/td&gt;

            &lt;td&gt;46&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
            &lt;th scope="row"&gt;Walk&lt;/th&gt;

            &lt;td&gt;21&lt;/td&gt;
            &lt;td&gt;16&lt;/td&gt;
            &lt;td&gt;13&lt;/td&gt;
            &lt;td&gt;15&lt;/td&gt;

            &lt;td&gt;12&lt;/td&gt;
            &lt;td&gt;13&lt;/td&gt;
        &lt;/tr&gt;

    &lt;/tbody&gt;

&lt;/table&gt;
</pre>
<h3>Breaking the markup down</h3>
<p>It’s worth noting at this point that it’s a good idea to include the <code>summary</code> attribute and the <code>caption</code> tag in your tables, so people using screen readers know immediately what the table is about. Remember that you can only add the <code>caption</code> immediately after the <code>table</code> start tag.</p>
<p>You should use the <code>thead</code>, <code>tbody</code> and <code>tfoot</code> tags, to wrap the different type of content in a more semantic way. This will also make the table header and table foot printed in all pages, in tables that spread across more than one page. Note that you can only use one <code>thead</code> and <code>tfoot</code> per table, but you may have one or more <code>tbody</code> tags.</p>
<p>For each cell of our table, we either have a <code>th</code> or a <code>td</code>, depending if it&#8217;s a header or a simple data cell. Each row in our table is closed within <code>tr</code> tags &#8211; table row.</p>
<p>A <code>th</code> tag is an element that refers to a table header.  These commands tell content in table cells to appear in header form; just like any header in a document. This makes it ideal for titles and other headers at the top of columns, etc. </p>
<p>In the <code>th</code> elements, we defined whether that header affects the row or the column of data by using the <code>scope</code> attribute. Also, because 2 of the <code>th</code> span across more than one row or column, we use the <code>colspan</code> and <code>rowspan</code> attributes to indicate how many rows or columns that element will span across.</p>
<p>The other tag that’s available for us to use is the <code>td</code> or table data tag. This differs from the <code>th</code> tag because it tells the content to just appear as a regular body of text without any specific formatting, such as: bold, italic or underlined. This makes it ideal for regular data cells.</p>
<h3>The CSS</h3>
<p>Now let&#8217;s make this table look better with some CSS goodness.</p>
<p>First we&#8217;ll deal with resetting margins and paddings and overriding the default bold font of the headers:</p>
<pre>
table, caption, td, tr, th {
	margin:0;
	padding:0;
	font-weight:normal;
	}
</pre>
<p>Second, we&#8217;ll define the width of the table, and make sure our cells have no spaces around them. We&#8217;ll also style the <code>caption</code> element, by aligning it to the left and setting the font size and padding:</p>
<pre>
table {
	border-collapse:collapse;
	margin-bottom:15px;
	width:90%;
	}

	caption {
		text-align:left;
		font-size:15px;
		padding-bottom:10px;
		}
</pre>
<p>Next step: let&#8217;s add some breathing space around our cells and define a little white bottom and right border for each. We already saw that all our data is either within a <code>th</code> or a <code>td</code> tag, so we&#8217;ll point to those in our stylesheet:</p>
<pre>
	table td,
	table th {
		padding:5px;
		border:1px solid #fff;
		border-width:0 1px 1px 0;
		}
</pre>
<p>Now we can start adding some details that will make our table easier to read. For example, let&#8217;s give a different colour for the <code>th</code> cells depending if they&#8217;re within the <code>thead</code> or the <code>tbody</code>, and then we&#8217;ll darken the ones with a <code>colspan</code> or <code>rowspan</code> attributes. This will only work in some browsers (because we&#8217;ll be using the <a href="http://www.w3.org/TR/CSS2/selector.html#attribute-selectors" rel="nofollow"  title="Visit the W3C documentation on Attribute Selectors">attribute selector</a>), but it will still look OK in less compliant ones.</p>
<pre>
	thead th {
		background:#91c5d4;
		}

		thead th[colspan],
		thead th[rowspan] {
			background:#66a9bd;
			}

	tbody th,
	tfoot th {
		text-align:left;
		background:#91c5d4;
		}
</pre>
<p>This is a very simple approach to the attribute selectors. Breaking it down:</p>
<pre>
thead th[colspan] { background:#66a9bd; }
</pre>
<p>We&#8217;re basically saying that for every <code>th</code> within the <code>thead</code> that has the <code>colspan</code> attribute defined, that is the background we want it to have. It will work independent of the value that we give to the attribute, as long as the element has it. We could have used it for any type of attribute, just using the following selector template:</p>
<pre>
selector[attribute] { property: value; }
</pre>
<p>For further reading on this subject, you can take a look at the links at the end of this post.</p>
<p>Going back to our table, we still have to take care of our <code>td</code> elements:</p>
<pre>
	tbody td,
	tfoot td {
		text-align:center;
		background:#d5eaf0;
		}
</pre>
<p>Because the last row represents the average commute time for all the modes, we&#8217;ll style it a bit differently:</p>
<pre>
	tfoot th {
		background:#b0cc7f;
		}

	tfoot td {
		background:#d7e1c5;
		font-weight:bold;
		}
</pre>
<p>Remember that in this case, we only have one table in our file, so these CSS selectors are very generic, but you can have more specific selectors, for example, if you only want to style a particular table within your website, or if you have different styles for different tables. You could do that by adding an <code>id</code> or a <code>class</code> to your table and specifying it within the CSS. For example:</p>
<pre>
table#travel {
	border-collapse:collapse;
	margin-bottom:15px;
	width:90%;
	}

	table#travel caption {
		text-align:left;
		font-size:15px;
		padding-bottom:10px;
		}

	table#travel table td,
	table#travel table th {
		padding:5px;
		border:1px solid #fff;
		border-width:0 1px 1px 0;
		}

	table#travel thead th {
		background:#91c5d4;
		}
</pre>
<h3>Some jquery to the equation</h3>
<p>Sometimes tables can become very long and hard to read. It&#8217;s not really our case, but it would still be helpful if we could add a different colour for when we&#8217;re hovering each data row, so we don&#8217;t have to move our fingers across the screen to guide us to the right header.</p>
<p>We could easily do this by adding a CSS pseudo class (<code>:hover</code>) to our <code>tr</code> elements, but that wouldn&#8217;t work in some less modern browsers, would it? And with a few simple &#8220;cut &#038; paste&#8221; lines of <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow"  title="Visit the jQuery Wikipedia entry">jQuery</a> we&#8217;ll make sure it works in browsers like Internet Explorer 6 and 7.</p>
<p>First, let&#8217;s create a new CSS style for when the <code>tr</code>s are hovered over:</p>
<pre>
	tbody tr.odd td {
		background:#bcd9e1;
		}
</pre>
<p>We&#8217;ll later make sure that the jQuery adds the class &#8220;odd&#8221; to the hovered <code>tr</code>s.</p>
<p>Second we&#8217;ll have to <a href="http://docs.jquery.com/Downloading_jQuery" rel="nofollow" >download the latest version of jQuery</a> from its website and then link to it on our html file. Add the following code inside the <code>head</code> tags (and make sure to change the file paths to suit your needs):</p>
<pre>
&lt;script type="text/javascript" src="js/jquery-1.2.6.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/style-table.js"&gt;&lt;/script&gt;
</pre>
<p>I&#8217;m not putting the javascript code directly into the html file &#8211; like I&#8217;m not adding the CSS either -, because separating the content from the rest will make for a cleaner and lighter file, and, let&#8217;s not forget, easier to update!</p>
<p>So we&#8217;ll create a javascrip file and name it style-table.js. In that file we&#8217;ll paste the following lines of code:</p>
<pre>
$(document).ready(function () {

	$('tbody tr').hover(function() {
	  $(this).addClass('odd');
	}, function() {
	  $(this).removeClass('odd');
	});

});
</pre>
<p>Ignore the rest and focus on this part: <strong>(&#8217;tbody tr&#8217;)</strong>. This is telling the script to look for a <code>tr</code> within the <code>tbody</code>. You could do something like: <strong>(&#8217;.mytable tr&#8217;)</strong> if you wanted it applied to a specific table, for example.</p>
<p>Then, the scrip will add the class &#8220;odd&#8221;: <strong>.addClass(&#8217;odd&#8217;)</strong>. Again, you could name the class something different, like &#8220;hovered&#8221;, which would make the code look like this instead: <strong>.addClass(&#8217;hovered&#8217;)</strong>. Pretty simple, right? :)</p>
<h3>Conclusion</h3>
<p>Like I said in the beginning, HTML tables don&#8217;t have to be boring at all. Personally I enjoy styling them because I can really add little details that will make them look so much better and easier to read, and that will improve the overall usability and experience of my websites.</p>
<p>I hope this simple tutorial may have shed a light onto the often ignored and avoided <code>table</code> and that you may have as much fun as I do working with them!</p>
<p><a href="/examples/style-table.html" rel="nofollow" class="example" >View example</a> <a href="http://webdesignernotebook.com/downloads/4" class="files" title="CSS Table | 17.79 kB">Download source files</a></p>
<h3>Further reading</h3>
<ul>
<li><a href="http://www.w3.org/TR/html401/struct/tables.html" rel="nofollow" >Tables in HTML documents</a></li>
<li><a href="http://veerle.duoh.com/blog/comments/a_css_styled_table_version_2/" rel="nofollow" >A CSS styled table version 2</a></li>
<li><a href="http://24ways.org/2005/the-attribute-selector-for-fun-and-no-ad-profit" rel="nofollow" >The Attribute Selector for Fun and (no ad) Profit</a></li>
<li><a href="http://css.maxdesign.com.au/selectutorial/selectors_attribute.htm" rel="nofollow" >Attribute selectors</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/a-beautiful-table/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Adding Style with CSS: A Beautiful Form</title>
		<link>http://webdesignernotebook.com/css/a-beautiful-form/</link>
		<comments>http://webdesignernotebook.com/css/a-beautiful-form/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 00:12:16 +0000</pubDate>
		<dc:creator>inayaili</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://webdesignernotebook.com/wp_livesite/?p=27</guid>
		<description><![CDATA[Forms don&#8217;t have to be ugly and boring, and certainly don&#8217;t have to be inside tables to look nice and aligned. In this post we&#8217;ll take look at how to style a beautiful form using the power of semantic HTML and CSS. The beginning: HTML markup Let’s begin by creating a simple feedback form. Here’s [...]]]></description>
			<content:encoded><![CDATA[<p>Forms don&#8217;t have to be ugly and boring, and certainly don&#8217;t have to be inside tables to look nice and aligned.<br />
In this post we&#8217;ll take look at how to style a beautiful form using the power of semantic HTML and CSS.</p>
<p><span id="more-27"></span></p>
<h3>The beginning: HTML markup</h3>
<p>Let’s begin by creating a simple feedback form.  Here’s an example of the markup for one:</p>
<pre>
&lt;form action="form.php"&gt;

	&lt;p&gt;Send us your comments and feedback:&lt;/p&gt;

	&lt;ol&gt;

        	&lt;li&gt;

        		&lt;label for="name"&gt;Name&lt;/label&gt;
        		&lt;input type="text" name="name" id="name" /&gt;
        	&lt;/li&gt;

        	&lt;li&gt;
        		&lt;label for="email"&gt;Email&lt;/label&gt;

        		&lt;input type="text" name="email" id="email" /&gt;
        	&lt;/li&gt;

        	&lt;li&gt;
        		&lt;label for="website"&gt;Website&lt;/label&gt;
        		&lt;input type="text" name="website" id="website" /&gt;

        	&lt;/li&gt;

        	&lt;li&gt;
        		&lt;label for="message"&gt;Message&lt;/label&gt;
        		&lt;textarea name="message" id="message"&gt;&lt;/textarea&gt;
        	&lt;/li&gt;

        	&lt;li&gt;
        		&lt;button type="submit" id="send"&gt;Send&lt;/button&gt;
        	&lt;/li&gt;

    &lt;/ol&gt;

&lt;/form&gt;
</pre>
<h3>Breaking down the markup</h3>
<p>I used an ordered list to wrap the form elements so each list item is a pair for <code>label</code> + <code>input</code>/<code>textarea</code>. This will not only make it a bit easier to add the style to the form, but will also make the form look better and visually make more sense when no styles are applied to it.</p>
<p>Every element in the form has its own <code>label</code> (except those that have their value specified within the element itself, like <code>button</code>s and submit <code>input</code>s). </p>
<p>You might have previously seen forms on other websites that allow you to select the labels, resulting in the right input will becoming highlighted. This removes the necessity of having to point precisely to the input fields &#8211; isn’t it more user friendly?</p>
<p>The way to achieve this is by defining which <code>label</code> belongs to which <code>input</code> (or <code>textarea</code>s, <code>select</code>s, etc.), and you do that with the <code>for</code> attribute (in the <code>label</code>s) in conjunction with the <code>id</code> attributes in the <code>input</code>s.</p>
<p>When creating the form, I didn&#8217;t use the <code>fieldset</code> or <code>legend</code> tags because our form is simple and short, so there’s really no point to separating it into more than one <code>fieldset</code>, and the paragraph explains what the form is about without being repeated by the screen-readers with each and every <code>label</code> (like <code>legend</code>s are).</p>
<p>It’s also worth noting that in this example I chose the <code>button</code> tag, instead of the <code>input</code> tag, for the submit button. This decision was made to give you more options in terms of what you can visually do with it.</p>
<h3>Adding the style</h3>
<p>Moving onto the CSS part of the form, we&#8217;ll start by resetting the default styles, adding some style to our <code>form</code> tag &#8211; font, background, margins and padding. We&#8217;ll also add a bottom margin to our paragraph.</p>
<pre>
body {
	margin:0;
	padding:0;
	}

p {
	margin:0 0 10px 0;
	padding:0;
	}

form {
	font:13px Georgia, "Times New Roman", Times, serif;
	background:#eee;
	margin:20px;
	padding:10px 20px;
	width:330px;
	}
</pre>
<p>Now, let&#8217;s style the ordered list and then make some tweaks for the one that holds the submit button (to which we gave a specific <code>id</code> of &#8220;send&#8221;).</p>
<pre>
	form ol {
		list-style:none;
		margin:0;
		padding:0;
		}

		form li {
			padding:6px;
			background:#e1e1e1;
			margin-bottom:1px;
			}

			form li#send {
				background:none;
				margin-top:6px;
				}
</pre>
<p>Our form is taking shape now, but we still need to style the <code>label</code>s, the <code>input</code>s and the <code>textarea</code>. We should also add a different style for when our inputs are in focus.</p>
<pre>
		form label {
			float:left;
			width:70px;
			text-align:right;
			margin-right:7px;
			color:#0066CC;
			line-height:23px;	 /* This will make the labels vertically centered with the inputs */
			}

		form input,
		form textarea {
			padding:4px;
			font:13px Georgia, "Times New Roman", Times, serif;
			border:1px solid #999999;
			width:200px;
			}

			form input:focus,
			form textarea:focus {
				border:1px solid #666;
				background:#e3f1f1;
				}
</pre>
<p>Last, but certainly not least, let&#8217;s add some eye candy to the Send button:</p>
<pre>
		form li#send button {
			background:#003366 url(images/css-form-send.gif) no-repeat 8px 50%;
			border:none;
			padding:4px 8px 4px 28px;
			border-radius:15%; /* Don't expect this to work on IE6 or 7 */
			-moz-border-radius:15%;
			-webkit-border-radius:15%;
			color:#fff;
			margin-left:77px; /* Total width of the labels + their right margin */
			cursor:pointer;
			}

			form li#send button:hover {
				background-color:#006633;
				}
</pre>
<p>So what have we added in this last step? We changed the default border (<code>border</code>), background colour (<code>background</code>) and text colour (<code>color</code>) of the button to our own needs. We also added some padding to give the text some space to breath and extra left padding to add a little icon on the background.</p>
<p>The properties <code>border-radius</code>, <code>-moz-border-radius</code> and <code>-webkit-border-radius</code> are CSS3 properties that add rounded corners to our element. Because the <code>border-radius</code> property is still not widely implemented among browsers, we also have to use the browser specific properties that will make it work on Firefox (<code>-moz-border-radius</code>) and Safari (<code>-webkit-border-radius</code>). As you may have guessed, none of the available versions of Internet Explorer supports this feature, so it will be an added detail for more compliant browsers.</p>
<p>For the button to be nicely aligned with the other <code>input</code>s, we have to add the 77 pixels of left margin (which is the sum of the 70 pixels of the labels + 7 pixels for their right margin).</p>
<p>The <code>cursor:pointer</code> bit is not really necessary, but we&#8217;ll then make sure that when a user hovers over the button, the cursor will change to the hand. For browsers other than IE6, it will also change its colour to green (thanks to the <code>form li#send button:hover</code> property).</p>
<h3>Conclusion</h3>
<p>When it comes down to creating forms, there are actually a lot more things that you can do than meets the eye, just by using some simple CSS.  My point in this blog post has been to show that there’s no need to use a table to create visually attractive and usable forms. Especially when we can just as easily have a semantically correct and beautiful form with just a few lines of CSS and some extra hooks in your markup.</p>
<p><a href="/examples/style-form.html" rel="nofollow" class="example" >View example</a> <a href="http://webdesignernotebook.com/downloads/5" class="files" title="CSS Form | 2.24 kB">Download source files</a></p>
<p>P.S.: Don&#8217;t forget to give proper credit to <a href="http://www.famfamfam.com/" rel="nofollow" >famfamfam</a> (if you use it), for the beautiful Send button icon, that is part of the <a href="http://www.famfamfam.com/lab/icons/silk/" rel="nofollow" >Silk icons set</a>.</p>
<p>Ciao!</p>
<h3>Further reading:</h3>
<ul>
<li><a href="http://www.w3.org/TR/html401/interact/forms.html" rel="nofollow" >W3C &#8211; Forms in HTML documents</a></li>
<li><a href="http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/" rel="nofollow" >CSS-Based Forms: Modern Solutions</a></li>
<li><a href="http://www.smashingmagazine.com/2008/04/17/web-form-design-modern-solutions-and-creative-ideas/" rel="nofollow" >Web Form Design: Modern Solutions and Creative Ideas</a></li>
<li><a href="http://woork.blogspot.com/2008/02/beautiful-css-form.html" rel="nofollow" >Beautiful CSS Form</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://webdesignernotebook.com/css/a-beautiful-form/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
