<?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>Kashit &#187; CSS</title>
	<atom:link href="http://www.kashit.org/words/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kashit.org</link>
	<description>home to Ehsan Quddusi</description>
	<lastBuildDate>Sun, 28 Feb 2010 18:43:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ultimate guide to techniques for cross browser CSS</title>
		<link>http://www.kashit.org/design/css/ultimate-guide-to-techniques-for-cross-browser-css/</link>
		<comments>http://www.kashit.org/design/css/ultimate-guide-to-techniques-for-cross-browser-css/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 07:33:50 +0000</pubDate>
		<dc:creator>Ehsan Quddusi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML + XHTML]]></category>
		<category><![CDATA[browser reset]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[IE6 bugs]]></category>
		<category><![CDATA[IE6 Hacks]]></category>

		<guid isPermaLink="false">http://www.kashit.org/?p=388</guid>
		<description><![CDATA[<span class="dropcap">W</span>ith the advent of CSS,  the power of presentation in web pages was highly increased. Transition from old style writing of HTML pages to new wave of full life UIs has brought with it many concerns for the web designers. The major concern for web designers nowadays is to create cross browser complaint websites with as little variation across browsers as possible. Internet Explorer 6 being the major problem creator among the lot. Since IE6 still holds 10.2% of the browser market share, according to w3schools <a href="http://www.w3schools.com/browsers/browsers_stats.asp">browser statistics</a> for January 2010, it needs to be tackled. Most of these problems are mainly caused due to variation in the implementation of specifications by browser vendors.]]></description>
			<content:encoded><![CDATA[<p><span class="dropcap">W</span>ith the advent of CSS,  the power of presentation in web pages was highly increased. Transition from old style writing of HTML pages to new wave of full life UIs has brought with it many concerns for the web designers. The major concern for web designers nowadays is to create cross browser complaint websites with as little variation across browsers as possible. Internet Explorer 6 being the major problem creator among the lot. Since IE6 still holds 10.2% of the browser market share, according to w3schools <a href="http://www.w3schools.com/browsers/browsers_stats.asp">browser statistics</a> for January 2010, it needs to be tackled. Most of these problems are mainly caused due to variation in the implementation of specifications by browser vendors.</p>
<h4>Global CSS Reset</h4>
<p>Different web browsers having their own defaults defined for most of the CSS properties and thus pose a problem in cross browser compliancy of front-ends. In order to address this, you should use CSS resets which brings the browser defaults to a same value across browsers. Various CSS resets are available in the web world, among which, Eric Meyer’s Reset Reloaded, YUI Reset CSS, Siolon’s global reset, Shaun Inman’s Global Reset &amp; Tantek’s CSS reset  are notable. Personally I use Eric’s Reset Reloaded because it neutralizes virtually every default CSS rule of browser.</p>
<pre name="code" class="css">/* v1.0 | 20080212 */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
   margin: 0;
   padding: 0;
   border: 0;
   outline: 0;
   font-size: 100%;
   vertical-align: baseline;
   background: transparent;
}

body {
   line-height: 1;
}

ol, ul {
   list-style: none;
}

blockquote, q {
   quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
   content: '';
   content: none;
}

/* remember to define focus styles! */
:focus {
   outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
   text-decoration: none;
}

del {
   text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
   border-collapse: collapse;
   border-spacing: 0;
}
</pre>
<h4>Easy Selectors</h4>
<p>These are the valid CSS selectors to address a particular browser or browser version. Most of the time, this technique is used for Internet Explorer only, although we can use it with every other browser. Below is the usage of selectors for addressing different browsers.</p>
<p>IE 6 and below</p>
<pre name="code" class="css">* html {}</pre>
<p>IE 7 and below</p>
<pre name="code" class="css">*:first-child+html {} * html {}</pre>
<p>IE 7 only</p>
<pre name="code" class="css">*:first-child+html {}</pre>
<p>IE 7 and modern browsers only</p>
<pre name="code" class="css">html&gt;body {}</pre>
<p>Opera versions 9 and below</p>
<pre name="code" class="css">html:first-child {}</pre>
<p>Google Chrome</p>
<pre name="code" class="css">body:nth-of-type(1) p {
   color: #333333;
}
</pre>
<p>Apple Safari</p>
<pre name="code" class="css">html:lang(en)&gt;body  .classname {}</pre>
<h4>IE Conditional Comments</h4>
<p>This technique is used to address some CSS for Internet Explorer only and make other browsers to simply avoid it or report it as comment. It works by putting up your code in comment style IE Conditional tags.</p>
<pre name="code" class="html">&lt;!--[if IE ]&gt;
   &lt;link href="iecss.css" rel="stylesheet" type="text/css"&gt;
&lt;![endif]--&gt;
</pre>
<p>Again we can use different sytax to address a particular browser versions like</p>
<pre name="code" class="html">&lt;!--[if IE6 ]&gt;
   &lt;link href="iecss.css" rel="stylesheet" type="text/css"&gt;
&lt;![endif]--&gt;

&lt;!--[if lt IE6 ]&gt;
   &lt;link href="iecss.css" rel="stylesheet" type="text/css"&gt;
&lt;![endif]--&gt;
</pre>
<p>You can read more about version targeting IE at <a href="http://www.quirksmode.org/css/condcom.html">quirksmode.org</a></p>
<h4>Transparent PNGs</h4>
<p>Although all the modern browsers support transparency for PNGs, yet again Internet Explorer 6 has a problem with it. IE6 displays a white patch beneath the PNG image. There are lot of scripts / techniques / solutions available to tackle this problem. One of the solution is to use <a href="http://www.kashit.org/design/png-transparency-for-internet-explorer/">HTC script</a> with your page. Many other plugins and scripts are available to tackle this problem. <code>jQuery pngFix</code>, <code>jQuery iepngfix</code> are used alongwith jQuery. I personally use <a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/">DD_belatedPNG</a>.</p>
<p>According to its author</p>
<blockquote><p>This is a Javascript library that sandwiches PNG image support into IE6 without much fuss</p></blockquote>
<p>It has support for PNGs in background or in SRC of an <code>&lt;img/&gt;</code> element. It also fixes <code>background-position</code> and <code>background-repeat</code> properties of CSS, which creates a problem with other scripts used. It uses Microsoft’s buddy, <code>VML</code> to fix the issues.</p>
<p>Here is its usage</p>
<pre name="code" class="html">&lt;!--[if IE 6]&gt;
&lt;script src="DD_belatedPNG.js"&gt;&lt;/script&gt;
&lt;script&gt;
/* EXAMPLE */
DD_belatedPNG.fix('.png_bg');

/* string argument can be any CSS selector */
/* .png_bg example is unnecessary */
/* change it to what suits you! */
&lt;/script&gt;
&lt;![endif]--&gt;
</pre>
<h4>Fixing IE Box Model Bug</h4>
<p>This is perhaps the most common and frustrating bug in IE 6 and below. It is caused due to IEs different approach in calculating the total size of a box. Let us say you write</p>
<pre name="code" class="css">.box {
   width:100px;
   padding:10px;
   border:2px solid #CCC;
}
</pre>
<p>According to W3C specifications, the total width of the box should be <code>124px</code>, which all the modern browsers follow, while as IE calculates it as <code>100px</code> only.</p>
<p>This deviation from the specs can cause lot of layout problems. IE 6 can actually get it right if you are in standards-compliant mode. There are various workarounds for this problem. Some of them are:</p>
<h5>Box-in-a-Box</h5>
<p>According to this technique, we simply use extra markup to fix the issue. Instead of using the padding on the main element, we insert another element inside it and use padding on it. Like</p>
<pre name="code" class="html">&lt;div class=”box”&gt;
  &lt;div class=”box-inner”&gt;
    Testing for box model hack
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>In this case our markup will be</p>
<pre name="code" class="css">.box { width:100px;}
.box-inner {padding:10px;}
</pre>
<h5>Simplified Box Model Hack (SBMH)</h5>
<p>It uses the CSS parsing  bug of Internet Explorer to address the issue. This was first detailed by <a href="http://www.doxdesk.com/personal/posts/css/20020212-bmh.html">Andrew Clover </a></p>
<p>The structure for this hack is</p>
<pre name="code" class="css">.box {
   padding:20px;
   width: 100px;
   \width: 140px;
   w\idth: 100px;
}
</pre>
<p>The first line &#8220;<code>width: 100px;</code>&#8221; is for browsers like Mozilla and Opera that render correctly. Opera and other browsers choke on the escape character (\) and so will ignore the second and third properties. The second property &#8220;<code>\width: 140px;</code>&#8221; is for IE 5 and 6/quirks mode. The final line &#8220;<code>w\idth: 100px;</code>&#8221; will be read by escape friendly browsers (including IE 6 in non-quirks mode) and set the width back to 100px.</p>
<h5>box-sizing</h5>
<p>The newly introduced CSS3 <code>box-sizing</code> property allows you to choose which box-model your browser should use. The W3C box model is called `<code>content-box</code>` and the Internet Explorer box model is called `<code>border-box</code>`.</p>
<p>This can make it easier to control the size of elements and to make sizes behave the same across different browsers.</p>
<pre name="code" class="css">.box {
   -moz-box-sizing: border-box;
   -webkit-box-sizing: border-box;
   box-sizing: border-box;
}
</pre>
<p>If the website is rendered in quirks mode, IE6 will render using the non-standard box model, so it will already be rendering as if it had the “<code>border-box</code>” property on. Modern browsers will adopt the IE’s buggy box-model by setting this property.</p>
<h4>Hover State</h4>
<p>All the modern browsers support <code>:hover</code> pseudo-class for about any element, but IE 6 has the support for hover pseudo class on &lt;a&gt; element only (you need to set the href attribute for <code>&lt;a&gt;</code> element to get this working in IE6). To fix this issue with IE6, you need a proprietary fix for this.</p>
<p><a href="http://www.xs4all.nl/~peterned/csshover.html">Whatever:hover</a> is a small script that automatically patches <code>:hover</code>, <code>:active</code> and <code>:focus</code> for IE6, IE7 and IE8 quirks, letting you use them like you would in any other browser.</p>
<p>Download the script file and add this line in your CSS file, and you are done.</p>
<pre name="code" class="css">body { behavior: url("csshover3.htc"); }
</pre>
<p>Note that behavior URLs are relative to the html file, not to the CSS file like a background image URL would be.</p>
<h4>Double Margin Bug</h4>
<p>Most of the people working with Web will be familiar with IE’s double margin bug. The bugs arises when you float an element to one side and apply some margin on that side. Without any reason, it simply doubles that margin.</p>
<p>For example, if we do this,</p>
<pre name="code" class="css">.box {
   float: right;
   margin-right: 10px;
}
</pre>
<p>IE6 will double the margin (most of the times) to 20px without any reason. But this bug can be easily overruled by changing the display property of the floated element from block to inline. So the CSS will be</p>
<pre name="code" class="css">.box {
   float: right;
   margin-right: 10px;
   display: inline;
}
</pre>
<h4>Stepdown problem in IE6</h4>
<p>When you float elements of a fixed width, they will align themselves horizontally to fit the width of the parent element. At least, that’s how it works in most browsers. In IE6, the floated items will not be displayed in a straight line, but rather will appear to stepdown in bizarre, staircase-like fashion. This can be fixed by applying <code>display: inline;</code> property to floated elements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kashit.org/design/css/ultimate-guide-to-techniques-for-cross-browser-css/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Best Practices &#8211; II</title>
		<link>http://www.kashit.org/design/css-best-practices-ii/</link>
		<comments>http://www.kashit.org/design/css-best-practices-ii/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 16:25:13 +0000</pubDate>
		<dc:creator>Ehsan Quddusi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[browser grading]]></category>
		<category><![CDATA[CSS Best Practices]]></category>
		<category><![CDATA[css hacks]]></category>

		<guid isPermaLink="false">http://www.kashit.org/?p=209</guid>
		<description><![CDATA[<span class="dropcap">I</span> hope you will have read my previous article on CSS Best Practices. This is another topic on the same subject, just to increase your knowledge of the CSS golden rules, tips &#38; tricks. The inspiration for this article is from my day to day experience with the same.]]></description>
			<content:encoded><![CDATA[<p><span class="dropcap">I</span> hope you will have read my previous article on CSS Best Practices. This is another topic on the same subject, just to increase your knowledge of the CSS golden rules, tips &amp; tricks. The inspiration for this article is from my day to day experience with the same.</p>
<p><em>Previous Article <a href="http://www.kashit.org/design/css-best-practices/">CSS Best Practices</a></em></p>
<h4>Avoid in-line css</h4>
<p>Use of inline styles hinders the purpose of CSS and should not be used in a live site.</p>
<h4>Test your code in A-Grade browser</h4>
<p>Test your code in an advanced browser before checking it in a broken browser. Building the site on a broken browser results in your code relying on the rendering of that browser and breaking on standards-complaint browser.Instead start from perfection and then hack for the less able browsers.</p>
<h4>Minimize and cleanup your code</h4>
<p>Use as little CSS as possible, remove styles and parts of styles not being used or that were experimented with in the design process. You can even use some compressors to compress the code by removing unwanted white space and line breaks.</p>
<h4>Combine Selectors</h4>
<p>Use inheritance to minimize your code as much as possible, like this.</p>
<p>Instead of writing</p>
<pre name="code" class="css">
h1 {
  font-family:Arial, sans-serif;
  font-size:2em;
  font-weight:bold;
  font-style:normal;
  color:#DE43A2;
}

h1 .title {
  font-family:Arial, sans-serif;
  font-weight:bold;
  font-style:normal;
  color:#CCC;
}
</pre>
<p>We can write</p>
<pre name="code" class="css">
h1 {
  font-family:Arial, sans-serif;
  font-size:2em;
  font-weight:bold;
  font-style:normal;
  color:#DE43A2;
}

h1 .title {
  color:#CCC;
}
</pre>
<h4>Use generic font families</h4>
<p>While assigning fonts to the font-family cssproperty, always follow your fonts by a generic font family of that type like serif, sans-serif etc This will make any font available from that family substitute to the font, mentioned by you in the style and not available in the client computer.</p>
<h4>Target your stylesheet</h4>
<p>While linking your stylesheet in your document, specify the media in which to be used like print, screen, projection etc</p>
<pre name="code" class="html">&lt;link rel="stylesheet" src="style.css" media="screen" /&gt;</pre>
<h4>Name your styles properly</h4>
<p>Never name your styles on the basis of their properties or the appearance they are going to make, like arialblue5, redbox etc. Instead name the styles in terms of usage like sub-head, sidebar-box etc.  One of the most important benefits of CSS is being able to change the look without having to change the HTML.</p>
<p>Use functional names for your classes, avoid words that describe how they look.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kashit.org/design/css-best-practices-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Best Practices</title>
		<link>http://www.kashit.org/design/css-best-practices/</link>
		<comments>http://www.kashit.org/design/css-best-practices/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 09:40:18 +0000</pubDate>
		<dc:creator>Ehsan Quddusi</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[browser reset]]></category>
		<category><![CDATA[CSS Best Practices]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[IE Conditional]]></category>
		<category><![CDATA[shorthand css]]></category>

		<guid isPermaLink="false">http://new.kashit.org/?p=48</guid>
		<description><![CDATA[<span class="dropcap">C</span>SS Best Practices is the topic that I had been planning to write on for months. As CSS is the order of the day as far as web related UI is concerned, more people are moving to it. CSS isn't always easy to deal with. CSS coding can sometimes become a nightmare, particularly if you're not sure which selectors are applied to document elements. CSS Best Practices covers some important and easy to remember tricks and tips to better manage, organise and develop your CSS Snippets.]]></description>
			<content:encoded><![CDATA[<p><span class="dropcap">C</span>SS Best Practices is the topic that I had been planning to write on for months. As CSS is the order of the day as far as web related UI is concerned, more people are moving to it. CSS isn&#8217;t always easy to deal with. CSS coding can sometimes become a nightmare, particularly if you&#8217;re not sure which selectors are applied to document elements. CSS Best Practices covers some important and easy to remember tricks and tips to better manage, organise and develop your CSS Snippets.</p>
<h4>Use a browser reset</h4>
<p>One of the most common mistakes that designers fall victim to when it comes to CSS is not resetting their browser defaults. This leads to inconsistencies in the appearance of your desing across different browsers. So before doing anything else, when coding a website, you should reset the styling. You can use a simple reset with the universal selector like this<br />
<code><br />
* { margin:0;padding:0;}<br />
</code><br />
But using the universal selector is sometimes a bad idea as it is very heavy on the rendering agent to apply rules to every single element in the document.</p>
<p>One of the most popular browser resets is of <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/" target="_blank">CSS Reset</a> by Eric Meyer. As Meyer says, “the styles should list all the actual elements to be reset and exactly how they should be reset.”</p>
<p>Another Browser Reset Library is Yahoo! UI Library: <a href="http://developer.yahoo.com/yui/reset/" target="_blank">Reset CSS</a>. It removes and neutralizes the default styling of html elements providing a foundation upon which you can explicity declare your extentions.</p>
<p>Another very useful CSS reset is <a href="http://warpspire.com/features/css-frameworks/">CSS Global Styles Reset</a> by Kyle Neath. A simple CSS Reset with some additional classes for better debugging.</p>
<h4>Size text without using pixels</h4>
<p>Web Designing best principles is to enable a site to withstand a user enlarging text and setting absolute text sizes is not a good practice. Instead we can size our text relative to the browser. Standard browser font size is 1em which is equal to 16px. A little web designer trick works around the issue and resets the font sizes for the entire site so that 1em is equal to 10 px.<br />
<code><br />
body { font-size:62.5%; }<br />
</code><br />
Simply throwing the font-size to 62.5% for the entire site does the trick. Now you can use em instead of pixels.</p>
<h4>Organise your CSS Code</h4>
<p>Organising your CSS code helps you with future maintainability of your site. You should make independent style sheets for different purposes and then linke them in your master stylesheet. Like you should maintain your typographic styles and structure selectors independently in different stylesheets and then link them together in your master stylesheet.<br />
<code><br />
@import url("reset.css")<br />
@import url("structure.css")<br />
@import url("typography.css")<br />
</code></p>
<h4>Make your code easy to read</h4>
<p>While scanning through CSS, I came across a very nicely separated CSS coded probably by Rundle. It looked something like this:<br />
<code><br />
h1 {}<br />
h1#title { font-size:2em; }</code></p>
<p>div {}<br />
div#error { color:#eee; }</p>
<p>This technique is very useful if you&#8217;re sharing code or working on a large site where you are using the same div tag in multiple places.</p>
<h4>Document your code</h4>
<p>This might be common sense to some of you but sometimes I look at CSS and it&#8217;s not documented at all. It is always a good practice to document your code or atleast provide a separate heading for a part of code as it makes working with code months or years later easier.<br />
<code><br />
/**********************************/<br />
/* Primary Navigation - Top Links */<br />
/*********************************/<br />
#nav {<br />
border:1px solid #eee;<br />
margin:10px auto;<br />
padding:5px;<br />
}</code></p>
<p>/***************/<br />
/* Search Box */<br />
/**************/<br />
#search-box {<br />
position:absolute;<br />
top:30px;<br />
left:30px;<br />
}</p>
<h4>Keep containers to minimum</h4>
<p>Avoid using too many Divs as it makes your document too much complex and tougher to handle. Avoid block level tags as much as possible and consider all options before using DIVs. New Developers to CSS often mistake DIVs for table cells and maximise their use to achieve the layout. Some people even style their headings with DIVs. Try using small tags or inline tags for goodness sake.</p>
<h4>Use Shorthand CSS</h4>
<p>Work smarter, not harder with CSS. You can wrap multiple properties within a single declaration by using special syntax. Avoid unnecessary properties as it directly effects your troubleshooting efforts.</p>
<h5>Like instead of writing</h5>
<p><code>margin-left:2px;<br />
margin-top:3px;<br />
margin-right:4px;<br />
margin-bottom:5px;<br />
</code></p>
<h5>You can write</h5>
<p><code>margin:3px 4px 5px 2px;<br />
</code><br />
Similarly we can use shorthand for border, background, padding, font and other properties.</p>
<h4>Specify Units</h4>
<p>Always specify units for the Property values unless it is 0. This a very common mistake among CSS beginners. In HTML you can get away with this but in CSS all length values should have a unit. While there&#8217;s no wrong in specifying a unit for 0 value, but for me it&#8217;s only a wastage of space.</p>
<pre class="css">padding:2px 3px 0 10px;</pre>
<h4>Working with Colors</h4>
<p>In hexadecimal notation, a color is represented by three pairs of hexadecimal digits. You can write a color more efficiently by omitting every second digit like this.</p>
<p><code>#ffffff</code> can be written as <code>#fff</code></p>
<p>Similarly <code>#ff3366</code> can be written as <code>#f36</code></p>
<p>Another color related tip is that you can specify web safe colors by using only digits that are multiples of 3 for the red, green and blue.</p>
<h4>Don&#8217;t redeclare inherited values</h4>
<p>The values of many properties are inherited by any descendants of the element that you specify the property for. So there is no fun of redeclaring those properties again and again. Some of the commonly inherited properties are of font and color.<br />
<code><br />
div { font-size:2em;color:#ef321d; }<br />
div.hello { font-size:2em;color:#ef23ef; }<br />
</code></p>
<h5>can be written as</h5>
<p><code>div { font-size:2em;color:#ef321d; }<br />
div.hello { color:#ef23ef; }<br />
</code></p>
<h4>Multiple Classes</h4>
<p>You can assign multiple classes to a single HTML element. This allows you to write several rules that define different properties and only apply them as needed. The multiple classes (assuming .head &amp; .head-about) can be applied to a single element like this.<br />
<code><br />
&lt;div class="head head-about"&gt;This is test for multiple classes&lt;/div&gt;<br />
</code></p>
<h4>Minimise CSS Hacks</h4>
<p>Hacks are the tricks, usually non-standard, to overcome some browser limitations. Don&#8217;t use hacks unless it is a known and documented bug as it makes the future maintenance of the code very difficult in absence of proper documentation and standard coding design.</p>
<h4>Define pseudo classes for links in the LoVe/HAte order</h4>
<p>Link, Visited, Hover &amp; Active, as the above represents. You should define your pseudo classes in this order<br />
<code><br />
a:link { color: blue; }<br />
a:visited { color: purple; }<br />
a:hover { color: purple; }<br />
a:active { color: red; }<br />
</code></p>
<h4>Define generic font families</h4>
<p>“When we declare a specific font to be used within our design, we are doing so in the hope that the user will have that font installed on their system. If they don’t have the font on their system, then they won’t see it, simple as that. What we need to do is reference fonts that the user will likely have on their machine, such as the ones in the font-family property below. It is important that we finish the list with a generic font type. [<a href="http://www.communitymx.com/content/article.cfm?cid=FAF76&amp;print=true">Getting into good coding habits</a>]<br />
<code><br />
p { font-family: Arial, Verdana, Helvetica, sans-serif; }<br />
</code></p>
<h4>1 ID per page, many classes per page</h4>
<p>“Check your IDs: Only one element in a document can have a certain value for the id attribute, while any number of elements can share the same class name. [..] Class and id names can only consist of the characters [A-Za-z0-9] and hyphen (-), and they cannot start with a hyphen or a digit (see CSS2 syntax and basic data types).” [<a href="http://www.456bereastreet.com/lab/developing_with_web_standards/css/" target="_blank">Roger Johansson</a>]</p>
<h4>Horizontally Centering an element</h4>
<p>It is very easy to center an element horizontally using HTML with the align attribute, but there is no such property in the CSS. Instead we use margin to center the element like this</p>
<pre class="css">margin:0 auto;</pre>
<p>Here &#8216;auto&#8217; automatically divides the space left on the sides of element into half and assigns each half on each side of the element</p>
<h4>Conditional Comments of IE</h4>
<p>IE versions less than 7 adhere to CSS standards very less and often create a nasty CSS bug or issue to deal with. You can come around the issue by creating a different style to address the issue and then include the style for only IE using IE conditional comments like this.<br />
<code><br />
&lt;!--[if IE]&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="ie.css" /&gt;<br />
&lt;![endif]--&gt;</code></p>
<p><em>Next Article in Series <a href="http://www.kashit.org/design/css-best-practices-ii/" title="">CSS Best Practices &#8211; II</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kashit.org/design/css-best-practices/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
