<?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>WebDea &#187; css hacks</title>
	<atom:link href="http://www.webdea.com/tag/css-hacks/feed" rel="self" type="application/rss+xml" />
	<link>http://www.webdea.com</link>
	<description>Converting PSD 2 HTML, xHTML, CSS, Wordpress, Joomla, Drupal</description>
	<lastBuildDate>Tue, 07 Dec 2010 12:48:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>How to Do Your Best with CSS Hacks for Internet Explorer</title>
		<link>http://www.webdea.com/do-your-best-css-hacks-ie.html</link>
		<comments>http://www.webdea.com/do-your-best-css-hacks-ie.html#comments</comments>
		<pubDate>Tue, 20 Apr 2010 15:46:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[w3c]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=54</guid>
		<description><![CDATA[<a href="http://www.webdea.com/do-your-best-css-hacks-ie.html"><img src="http://farm3.static.flickr.com/2711/4505034449_1a96c9e4bb_o.jpg" alt="browser CSS Hacks to know" align="left"></a>Sometimes it is rather difficult to make CSS-based sites to look perfect across all browsers. The main problem is in Internet Explorer implementing CSS commands differently to other browsers. Thus, with most difficulties caused by the same Internet Explorer CSS issues, these problems can be fixed.]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is rather difficult to make CSS-based sites to look perfect across all browsers. The main problem is in Internet Explorer implementing CSS commands differently to other browsers. Thus, with most difficulties caused by the same Internet Explorer CSS issues, these problems can be fixed. </p>
<h3>Fix Narrower Page Elements in Internet Explorer</h3>
<p><img src="http://farm5.static.flickr.com/4014/4505670034_c81a63503e_o.jpg" alt="cross browser CSS Hacks" align="right" /></p>
<p>The misinterpretation of the CSS box model that make page elements to be narrower in IE is probably the most usual IE and CSS issue. In short, every HTML element is a box, the width of which equals the total of its padding, border, margin and content area. Here is the sample of CSS rule:</p>
<blockquote><p>div {<br />
margin: 5em;<br />
padding: 4em;<br />
border: 1em solid green;<br />
width: 30em<br />
}</p></blockquote>
<p>It means that each div is 50em wide in total. You can make this amount just adding 30em wide content area to 4em padding, 1em border and 5em (invisible) margin on both the left and right sides. </p>
<p>In IE the padding and border are included in the width of the content. In other words, the width of the content is 20em only while the total width of the div is just 40em.</p>
<p>Such CSS box model problem will appear in IE5.x for sure and can occur in IE6, depending on the way you declare the ISO value in the HTML code. Here are the two variants possible:</p>
<ul>
<li>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;iso-8859-1&#8243;?&gt;</li>
<li>&lt;meta http-equiv=&#8221;content-type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&gt;</li>
</ul>
<p>The first command should be placed on the very first line of the HTML document. The second can be placed anywhere within the &lt;head&gt;. You must use one of these commands and according to W3C the first command is the better choice. </p>
<p>On the other hand, using the first command, you will make IE6 render the CSS box model incorrectly as in version 5 browsers. CSS hack allows you to fix the box model problem. With its help you can send different width values to different browsers. The choice of CSS hack to use will depend on ISO value and versions of IE. </p>
<p>Here are the CSS commands to fix IE5.x only:</p>
<blockquote><p>div {<br />
margin: 5em;<br />
padding: 4em;<br />
border: 1em solid green;<br />
width/**/:/**/ 40em;<br />
width: 30em<br />
}</p></blockquote>
<p>These CSS commands can be used to fix up all versions of IE:</p>
<blockquote><p>div {<br />
margin: 5em;<br />
padding: 4em;<br />
border: 1em solid green;<br />
width: 40em<br />
}<br />
html>body div {<br />
width: 30em<br />
}</p></blockquote>
<h3>Spilling Text Issue</h3>
<p>Unlike other browsers, IE expands background colours and borders to avoid text spilling out of its containing element. You will view the text splitting out of the right-hand side of the box in all browsers except IE, in case you have a box assigned class=&#8221;box&#8221; with the following CSS commands,:</p>
<blockquote><p>.box {<br />
width: 40px;<br />
border: 2px solid #781351;<br />
padding: 3px;<br />
background: #d7b9c9;<br />
white-space: nowrap<br />
}</p></blockquote>
<p>The box doesn’t expand in all other browsers except IE, because they will adhere to the width: 40px CSS command. While IE interprets width as min-width (the same works for height and min-height).<br />
To avoid spilling the text out of the box in all browsers you should use the first rule with the following CSS rule:</p>
<blockquote><p>html>body .box<br />
{<br />
width: auto;<br />
min-width: 40px<br />
}</p></blockquote>
<p>This command is for non-IE browsers only, because IE will ignore it because it has html>body at the front of it. Thus, the first CSS rule, width: auto, cancels out the original width rule while the second command, min-width: 40px then assigns a minimum width to the box that will always expand to fit the text.</p>
<h3>Background Images Disappear</h3>
<p><img src="http://farm5.static.flickr.com/4064/4505035831_b6e2230375_o.jpg" alt="cross browser CSS Hacks" align="right" /></p>
<p>The other problem is background images that disappear every time you scroll up and down on a web page. As a rule, you need to refresh the page to make the background reappear. The first solution is to insert the CSS command position: relative into the CSS rule containing the background image:</p>
<blockquote><p>.foo {<br />
background: url(filename.jpg);<br />
position: relative<br />
}</p></blockquote>
<p>However, sometimes it doesn’t change things for the better and you should assign a width or a height to the element with the background image. You can just assign a height of 1% for Internet Explorer. This CSS rule make no damage to appearance because IE interprets height as min-height:</p>
<blockquote><p>.foo {<br />
background: url(filename.jpg);<br />
height: 1%<br />
}<br />
html>body .foo {<br />
height: auto<br />
} </p></blockquote>
<p>The height: 1% CSS command is cancelled out by the height: auto CSS command. As soon as Internet Explorer doesn&#8217;t understand html>body, the second CSS rule will be ignored by IE.</p>
<h3>Widths Working on IE Only</h3>
<p>Every HTML element is a block or an inline element. For example, &lt;div&gt;, &lt;p&gt;, &lt;h1&gt;, &lt;form&gt; and &lt;li&gt; are block elements while &lt;span&gt;, &lt;a&gt;, &lt;label&gt;, &lt;strong&gt; and &lt;em&gt; are inline elements. All we know that the width of an inline element can&#8217;t be changed. In other words, the following CSS rule shouldn’t work:</p>
<blockquote><p>span {<br />
width: 100px<br />
}</p></blockquote>
<p>However, it works in IE. Thus, each span in IE will have a width of 100px while the width of the span in all other browsers will be the width of the number of characters contained in the element. The solution is to turn the span into a block level element just like this:</p>
<blockquote><p>span {<br />
width: 100px;<br />
display: block<br />
}</p></blockquote>
<p>Making the span a block element will cause the width command working in every browser. On the other hand, it also makes the span being on a new line. To avoid this you can assign float: left to the span. </p>
<h3>Unstyled Version of Web Page</h3>
<p>In case an unstyled version of the page appears for a moment, when you load your website in IE, you can see such phenomenon as the Flash Of Unstyled Content (or FOUC). </p>
<p>In case you use the @import directive (e.g. &lt;style type=&#8221;text/css&#8221;&gt;@import &#8220;styles.css&#8221;;&lt;/style&gt;) to call up your CSS file then it can happen on your website in IE. There is quite a simple solution to fix this problem. You just need to insert a link or a script element into the header. And it doesn’t really matter whether you insert one of them or both. It doesn&#8217;t matter which one you insert (or even if you insert both). Provide a print stylesheet, using the link element to reference it (as indicated in the example below), and forget about the FOUC phenomenon:</p>
<ul>
<li>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;scripts.js&#8221;&gt;&lt;/script&gt;</li>
<li>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;styles.css&#8221; type=&#8221;text/css&#8221; media=&#8221;print&#8221; /&gt;</li>
</ul>
<h3>Fixed Width Web Page Is Not in Centre of Window</h3>
<p>The centrally aligning content through CSS doesn&#8217;t work in IE:</p>
<blockquote><p>#container {<br />
width: 770px;<br />
margin: 0 auto<br />
}</p></blockquote>
<p>Thus, you can’t get a fixed width website to centrally align in the window in Internet Explorer or on the contrary, it is perfect in IE but not in any other browser.  </p>
<p>With the second command margin: 0 auto positioning the containing element in the centre of the browser window, we should use such command in IE:</p>
<blockquote><p>body {<br />
text-align: center<br />
}<br />
#container {<br />
width: 770px;<br />
margin: 0 auto;<br />
text-align: left<br />
}</p></blockquote>
<p>You also should insert text-align: left into the container div to avoid the text aligning too. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/do-your-best-css-hacks-ie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Basics of Cross Browser Compatibility and CSS Hacks Usage</title>
		<link>http://www.webdea.com/cross-browser-compatibility.html</link>
		<comments>http://www.webdea.com/cross-browser-compatibility.html#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:01:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[intenet explorer]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[opera]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=69</guid>
		<description><![CDATA[<a href="http://www.webdea.com/cross-browser-compatibility.html"><img src="http://farm3.static.flickr.com/2255/4514004287_717126490f_o.jpg" alt="Cross Browser Compatibility" align="left"></a>It is necessary for a good CSS developer to be familiar with the individual browsers and know what CSS versions and levels of compliancy they support. Take into consideration the flaws of IE design and the things that look perfect in Mozilla browsers and terrible in Internet Explorer as well as just break in Netscape.]]></description>
			<content:encoded><![CDATA[<p>Cross browser compatibility is one of the problematic issues of CSS (Cascading Style Sheets). The things that look perfect in Mozilla browsers can be terrible in Internet Explorer as well as just break in Netscape. Of course, the largest group of viewers use IE, but still web developers should take into consideration the flaws of IE design for all other browsers as well.</p>
<h3>Browsers – The Main Differences</h3>
<p><img src="http://farm5.static.flickr.com/4019/4514643736_700d70b7a1_o.jpg" alt="CSS Hacks to remember" align="right" /></p>
<p>It is necessary for a good CSS developer to be familiar with the individual browsers and know what CSS versions and levels of compliancy they support. Knowing why they do what they do is a crucial part. Of course, you may not know all the ins and outs of the browsers. Your task is to understand the vast majority of differences among them.</p>
<p>Here you can find some principles concerning each browser that help you a lot. The browsers that will be explained are Mozilla and Firefox, Safari, Internet Explorer 5+ for Windows and Mac, Opera and Netscape 6+.</p>
<p>There are quite a lot of other browsers such as Mozilla’s browser project Camino for Mac, Konqueror or Maxthon. In short, there are really too many of them to cover in this post. The other thing is that most of them are based on the same technologies as the browsers we have mentioned above. Thus, Maxthon is based on IE; and if it works on Firefox, it’s very likely going to work on Mozilla and Camino.</p>
<p><strong>Mozilla and Firefox</strong></p>
<p>The Mozilla Group offers you the open-source Gecko browser engine that is used by the Mozilla browser suite as well as by a diverse range of products. It should be noted that Gecko is highly standards-compliant. It is supported by many platforms. Firefox is a Mozilla browser. Such Mozilla based browsers like Firefox are considered to be the earliest browsers that support CSS quite well.</p>
<p><strong>Safari for Mac</strong></p>
<p>Safari is an OS X browser that uses a variant of Konqueror&#8217;s KHTML browser engine. There are three reasons why Apple chose to base Safari on KHTML instead of Gecko: KHTML was faster, KHTML&#8217;s source code is smaller and cleaner, and Apple doesn&#8217;t need Gecko&#8217;s multi-platform support.  On the whole, this browser behaves like Mozilla.</p>
<p><strong>Opera</strong></p>
<p>Made by Opera Software, the Opera browser can work with various operating systems including embedded systems. Opera is well known as fast, small and standards-compliant browser that is available on many platforms. It fully supports CSS 2.1, so your validated CSS will render properly in Opera with the strict doctype as well as in quirks mode.</p>
<p><strong>Netscape 6 and up</strong></p>
<p>In comparison with other browsers Netscape 6 has the best CSS support on the web. Only Mozilla browsers can be proud of fewer bugs. On the whole, Netscape is rather similar to Mozilla browsers and even tries to introduce a different type of style sheet in JavaScript in order to avoid CSS compliancy altogether.</p>
<p><strong>Internet Explorer 5 and up</strong></p>
<p>With the huge improvement in CSS support for Internet Explorer when Microsoft updated IE3 to IE4, as well as with newer versions of IE problems that have been  solved in version 6 for Windows and 5.5 for Mac, IE remains to be quite buggy. For example, IE6 for Windows doubles margins of floated elements or duplicate text in multiple floats as well. All these issues can’t be covered within one article, so let’s try to find out the things that make different with regards to CSS compatibility.</p>
<p>Why are these browsers so different? The answer on this question is quite simple. There are no standards adopted by all the browser vendors. Thus, you need some practice and skill to make your site look the same across all the browsers.</p>
<p>The other important thing to consider is that Internet Explorer is used by almost 70% of people, while only about 30% use non-Microsoft browsers. Thus, among newest browsers IE provides you with the biggest problems with regards to compatibility. The main problem with IE is that is tries to assume what to do, instead of following your CSS instructions. It also doesn’t support many CSS standards that Mozilla and Netscape browsers do.</p>
<h3>Make Them Perfect for Your Page</h3>
<p><img src="http://farm3.static.flickr.com/2312/4514644128_64bbf5d8e5_o.jpg" alt="CSS Hacks For Cross Browser" align="right" /></p>
<p>Putting your web page for IE into quirks mode can help you to make IE do what you need. Quirks mode is a rendering mode where a browser tries to handle sloppy code in the way that they did in the mid- to late 90&#8242;s. This quirks mode allows the browser to imitate bugs in earlier browser versions so that they render the old, quirkily coded pages exactly the same as they used to.</p>
<p>However, if you put your page into quirks mode for IE you also do it for other browsers. Thus, you need to use a trigger that will switch between strict mode and quirks mode depending upon the type of browser. This is known as “doctype switching” and is supported by most modern browsers. According to the standards, any (X)HTML document should have a doctype which informs the browser of the version of (X)HTML the document is using.  Here is the example of doctype:</p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</p>
<p>Strict mode is also supported by modern browsers. To trigger strict mode the presence of the doctype is quite enough. In other words, your page doesn’t have to validate according to the chosen doctype. However, as any rule it has its exception. In IE6, the page displays in quirks mode if a doctype that triggers strict mode is preceded by an xml prologue:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;iso-8859-1&#8243;?&gt;</p>
<p>Thus, CSS coders can achieve valid pages that require a doctype, but still want their pages to render in quirks mode. Note that older browsers ignore this tag and doctype switching. They operate in quirks mode anyway.</p>
<h3>Another Solution to Try</h3>
<p>Creating multiple style sheets for multiple browsers is another solution of cross-browser compatibility. You just need to use a JavaScript code to return the version and type of browser the web visitor is using. Design issues are the other thing to pay attention to and CSS hacks that can help you a lot.</p>
<p>The “html&gt;body” selector is the first one to consider. It selects any body element that is a child of an HTML element. In order to interpret correctly, compliant browsers (except IE) need white space on either side of the child selector (html &gt; body or html&gt; body or html &gt;body:</p>
<blockquote><p>html&gt;body { overflow: visible; } /* show to IE */<br />
body { overflow: auto; } /* show to everyone else */</p></blockquote>
<p>Here is the underscore hack, which allows you to show CSS only to IE excluding all other browsers:</p>
<blockquote><p>body {<br />
background: blue; /* show to Mozilla/Safari/Opera */<br />
_background: red; /* show to IE */<br />
}</p></blockquote>
<p>This is quite useful if you need to give IE a set of separate instructions because something will appear wrong if you don’t.</p>
<p>However, this hack won’t work in IE5 for Mac. Thus, you need extra hack that is known as the Mac Backslash Hack. It allows IE5/Mac to ignore any CSS rules contained within the hack’s boundaries. Using a backslash before the asterisk: \*/ you hide the end-comment marker for IE5/Mac. In other words, IE5/Mac accepts anything which follows as a part of the comment while all other browsers understand and apply the following rules:</p>
<blockquote><p>body {<br />
background: blue; /* show to Mozilla/Safari/Opera */<br />
_background: red; /* show to IE */<br />
/* commented backslash hack for IE5-Mac \*/<br />
background: green;<br />
/* end hack */<br />
}</p></blockquote>
<p>As you see, CSS hacks can be rather complicated in case you don’t understand the bugs that the browsers have to begin with. Hope this info help you in some way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/cross-browser-compatibility.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Avoid CSS Hacks for Internet Explorer</title>
		<link>http://www.webdea.com/avoid-css-hacks.html</link>
		<comments>http://www.webdea.com/avoid-css-hacks.html#comments</comments>
		<pubDate>Tue, 13 Apr 2010 12:57:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[how to tips]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=67</guid>
		<description><![CDATA[<a href="http://www.webdea.com/avoid-css-hacks.html"><img src="http://farm5.static.flickr.com/4051/4514639826_2f3a7de9f1_o.jpg" alt="CSS Hacks to avoid" align="left"></a>With most web developers still confusing about the usage of CSS hacks and Internet Explorer some information about the code testing and implementing good CSS hacks is still necessary.The following examples from the code make your CSS will work perfectly across all browsers.]]></description>
			<content:encoded><![CDATA[<p>With most web developers still confusing about the usage of CSS hacks and Internet Explorer some information about the code testing and implementing good CSS hacks is still necessary. The following examples from the code help you to find out how to clean up some CSS hacks for IE.<img src="http://farm5.static.flickr.com/4019/4514640376_2f0bea35ae_o.jpg" alt="CSS Hacks to remember" align="right"> </p>
<p>According to Tantek Çelik, the CSS hacks guru, there are several rules that explain how CSS hacks should be designed for such a troublesome browser as Internet Explorer. First of all, they should be valid. The second rule is that CSS hacks should target only old/abandoned/frozen browsers/user-agents. And the last thing to know is that they should be ugly. Tantek also explains that using a feature of CSS is not a hack. </p>
<p>The star html bug and the underscore hack are the most often IE-specific hacks in the code. Let’s find out how they can be replaced with the same CSS feature-based solution. Here are some code samples of them both. </p>
<h3>The Star HTML Bug</h3>
<p>Targeting current as well as future UAs, this hack violates Tantek’s second rule. It can be found as a stand alone rule as well as an override to some other rule in a style sheet:</p>
<blockquote><p>* html div#header {margin-top:-3px;}</p>
<p> .promo h3 {min-height:21px;}<br />
 * html .promo h3 {height:21px;}</p></blockquote>
<h3>The Underscore Hack</h3>
<p>This hack violates Tantek’s first two rules: first of all, it is invalid according to the W3C CSS Validator. It also targets current UAs:</p>
<blockquote><p>ol {padding:0; _padding-left:5px;}</p></blockquote>
<h3>Child Selectors to Fix the Problem</h3>
<p><img src="http://farm3.static.flickr.com/2776/4514640928_7247d0f7c4_o.jpg" alt="CSS Hacks for all" align="right"></p>
<p>With the child selector we can replace both the underscore hack as well as the star html bug. The first step is to write the rules with selectors that can be applied to all browsers:   </p>
<blockquote><p>div#header {}</p>
<p> .promo h3 {}</p>
<p> ol {padding:0;}</p></blockquote>
<p>Then, add the IE-specific declarations to these rules: </p>
<blockquote><p>div#header {margin-top:-3px;}</p>
<p> .promo h3 {height:21px;}</p>
<p> ol {padding:0 0 0 5px;}</p></blockquote>
<p>Add the second rule after each rule. The selector of the second rule must use a child selector. Now correct any IE-specific declarations in this new rule:</p>
<blockquote><p>div#header {margin-top:-3px;}<br />
 body > div#header {margin-top:0;}</p>
<p> .promo h3 {height:21px;}<br />
 .promo > h3 {height:auto; min-height:21px;}</p>
<p> ol {padding:0 0 0 5px;}<br />
 html > body ol {padding:0;}</p></blockquote>
<p>Thus, you have no more hacks. Operating in strict mode and trying to bar some complicated stuff in your code, your CSS will work perfectly across all browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/avoid-css-hacks.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 Things to Know about CSS Hacks for Internet Explorer</title>
		<link>http://www.webdea.com/5-things-css-hacks-ie.html</link>
		<comments>http://www.webdea.com/5-things-css-hacks-ie.html#comments</comments>
		<pubDate>Fri, 09 Apr 2010 15:59:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=61</guid>
		<description><![CDATA[<a href="http://www.webdea.com/5-things-css-hacks-ie.html"><img src="http://farm3.static.flickr.com/2797/4505673332_6f90a31f44_o.jpg" alt="browser CSS Hacks for IE" align="left"></a>CSS hacks are necessary evil that helps us to do our best with default CSS rules. They remain to be essential to make our websites look great across various browsers and especially for Internet Explorer. The good thing is that there are only few of them that really matter. So, to create a list of the most necessary CSS hacks is quite possible.
]]></description>
			<content:encoded><![CDATA[<p>CSS hacks remain to be essential to make our websites look great across various browsers and especially for Internet Explorer. The good thing is that there are only few of them that really matter. So, to create a list of the most necessary CSS hacks is quite possible.</p>
<h3>1. Conditional Comments</h3>
<p>Conditional comments help to fix a lot of problems with IE and they are not supported by any other browser. That’s why they are safe to use. Here is the usual type:</p>
<p>&lt;blockquote&gt;&lt;!&#8211;[if IE]&gt;<br />
do something<br />
&lt;![endif]&#8211;&gt;&lt;/blockquote&gt;</p>
<p>Working on a layout you can place all hacks for some selector just after default rule. Thus, you can change everything quickly without searching for the corresponding hack in other places.<img src="http://farm5.static.flickr.com/4016/4505674290_1865f2af1e_o.jpg" alt="things to know about CSS Hacks" align="right" /></p>
<p>After finishing layout you can go through all of the CSS files again, in order to optimize everything and remove all hacks into separate file. Thus, the main CSS is neat.</p>
<p>This separate file can be called in the header section of a file within conditional comments:</p>
<p>&lt;blockquote&gt;&lt;!&#8211;[if IE]&gt;<br />
do something<br />
&lt;![endif]&#8211;&gt;&lt;/blockquote&gt;</p>
<p>The main CSS file has the hacked selectors starting with the * html. All browsers ignore this selector, because there are no elements above html in a document tree while IE allows us to use this flaw when applying IE specific hacks.</p>
<p>The following information should be taking into consideration as if we are dealing with separate file with IE hacks only.</p>
<h3>2. IE 5.x broken box model</h3>
<p>Broken layouts in IE5.x can appear because of a combination of width and padding on the same element. To fix this problem we should use backslash box model hack:</p>
<blockquote><p>someselector {<br />
padding: 10px;<br />
width: 200px;<br />
w\idth: 180px;<br />
height: 200px;<br />
heigh\t: 180px;<br />
}</p></blockquote>
<p>Thus, we have an element that is 200px wide, 200px high and with 10px paddings in both IE 5.x and IE 6.</p>
<h3>3. Everything floated?</h3>
<p>The other important rule to follow is to use extra rule <code>display: inline;</code> for everything floated and with a margin larger than zero.</p>
<h3>4. Prevent overflow problems</h3>
<p><img src="http://farm5.static.flickr.com/4069/4505674734_88aab1514b_o.jpg" alt="CSS Hacks for IE" align="right" /></p>
<p>The simple solution to prevent enlarging parent element horizontally that is caused by usage of italic font style in any IE version is the following:</p>
<blockquote><p>someselector {<br />
overflow-x: hidden;<br />
}</p></blockquote>
<h3>5. Font size in tables</h3>
<p>IE 5.x ignore font rules in tables in html or body element. Here is the simple solution of this problem:</p>
<blockquote><p>body {<br />
font-size: 62.5%;<br />
}<br />
table {<br />
font-size: 1em;<br />
}</p></blockquote>
<p>You also are free to change rules according to a particular table’s needs.</p>
<p>CSS hacks are necessary evil that helps us to do our best with default CSS rules. The other thing is to make it easily accessible in our memory… or just invent them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/5-things-css-hacks-ie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Browser Detection Using CSS Hacks Explained</title>
		<link>http://www.webdea.com/cross-browser-css-hacks.html</link>
		<comments>http://www.webdea.com/cross-browser-css-hacks.html#comments</comments>
		<pubDate>Tue, 06 Apr 2010 12:57:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[opera]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=45</guid>
		<description><![CDATA[<a href="http://www.webdea.com/cross-browser-css-hacks.html"><img src="http://farm3.static.flickr.com/2684/4496316573_5d347e39a9_o.jpg" alt="browser CSS Hacks to know" align="left"></a>All we know that CSS more attractive for web developers. However, there are still some problems that keep the developers from using it. The problem is in interpreting CSS commands in different ways that is a usual thing for browsers. Learn more about CSS and different browser interpretations stop to be a mystery for you. ]]></description>
			<content:encoded><![CDATA[<p>Quicker download time, easier site management as well as improved accessibility make CSS more attractive for web developers. However, there are still some problems that keep the developers from using CSS to control the layouts of the site. Let’s try to solve some of them. </p>
<h3>Mad with CSS?</h3>
<p><img src="http://farm5.static.flickr.com/4006/4496317117_3fb0f864ec_o.jpg" alt="cross browser CSS Hacks" align="right"></p>
<p>Today there are no problems concerning a lack of browser support for CSS because &#8216;version 5&#8242; browsers began to offer a full implementation of CSS. The problem is in interpreting CSS commands in different ways that is a usual thing for browsers. With such tricks appeared, many web developers prefer to switch back to pixel-perfect table layouts. But wait! Just learn more about CSS and different browser interpretations stop to be a mystery for you. What is more, there are not so many of them and using various hacks makes you life easier.</p>
<h3>How CSS Hacks Turn ‘Mad With’ Into ‘Mad About’</h3>
<p>CSS hacks work by sending one CSS rule to the browser or several browsers for your choice and the second CSS rule that overrides the first command to the other browsers. In case you have two CSS rules within the same selectors, the second CSS rule will almost always take priority. </p>
<p>For example, you need the space between a page&#8217;s header area and content to 25px in Internet Explorer. It may be great for Internet Explorer, but for Opera, Safari and Firefox this gap is not appropriate and you want to make a 10px gap instead. Here are two CSS rules that help you to perform the best in all browsers:</p>
<blockquote><p>#header {margin-bottom:25px}<br />
#header {margin-bottom:10px}</p></blockquote>
<p>In this case the first command is for IE while the second is for all other browsers. However, there is no good news by now, because all browsers can understand both CSS rules. In other words, they all use the second rule, because it comes after the first. </p>
<p>And now a CSS hack should be inserted to hide the second CSS rule from IE. In such a way, IE won’t know that the rule exists and just will use the first CSS rule. Seems to be quite simple? Let’s find out the details. </p>
<h3>Browser Detection for Internet Explorer</h3>
<p>If you need to send different CSS rules to IE, you can use the child selector command that IE can’t understand. This command consists of two elements one of which is the child of another. Thus, html>body refers to the child <u>body</u> with parent <u>html</u>. </p>
<p>Here is the example of the header margin that illustrates our CSS command:</p>
<blockquote><p>#header {margin-bottom:3em}<br />
<strong>html>body #header {margin-bottom:1em}</strong></p></blockquote>
<p>Because of the html>body CSS command, IE can’t understand the second CSS rule and ignore it using the first rule. All other browsers will use the second rule. </p>
<h3>Browser Detection for Internet Explorer 5</h3>
<p><img src="http://farm5.static.flickr.com/4026/4496954800_8d1edd4b4d_o.jpg" alt="CSS Hacks and browser detection" align="right"></p>
<p>IE5 requires different CSS rules because of its misinterpretation of the box model. For example, padding and borders are not included when we specify the width of some element in CSS. IE5 incorporates them both into the width value and, as a result, elements widths are smaller in this browser. </p>
<p>Here is the CSS rule that results in a width of 10em for all browsers except IE5 where the width will be 5em. IE5 just incorporate two sets of padding and border, on both the left and right, when calculating the width with the following rule:</p>
<blockquote><p>#header {padding: 2em; border: 0.5em; width: 10em}</p></blockquote>
<p>You can solve this problem using box model hack invented by famous Tantek Çelik. For browser detection and sending different CSS rule to IE5 you should use the following: </p>
<blockquote><p>#header {padding: 2em; border: 0.5em; width: 15em;<br />
<strong>voice-family: &#8220;\&#8221;}\&#8221;"; voice-family:inherit; width: 10em}</strong></p></blockquote>
<p>Don’t ask how it works. Just use it. Need details? IE5 will use the first width value of 15em. As we have mentioned above, 5em of it will be taken up by two sets of padding and border (for the left and for the right). That will cause the width of 10em in IE5.</p>
<p>The 15em value will be overridden by the second value of 10em by all other browsers except IE5, because it can’t understand the CSS command that comes immediately after all those squiggles. </p>
<p>However, nothing is perfect and the box model hack is not an exception to this rule. For example, it can ‘kill’ the next CSS rule in IE5. But there are a lot of other box model hacks that can help you. </p>
<h3>Browser Detection for Internet Explorer on the Mac</h3>
<p>IE on the Mac is also quite capricious with CSS. Thus, many developers code sites in such a way that they work in IE/Mac. Of course, it may not offer the same level of design or functionality that is offered with other platform or browser, but still it is a good solution. </p>
<p>To hide a command with IE/Mac hack is quite simple. Just wrap a set of stars and dashes around CSS rules: </p>
<blockquote><p><strong>/* Hide from IE-Mac \*/</strong><br />
#header {margin-bottom:3em}<br />
#footer {margin-top:1.5em}<br />
/* End hide */</p></blockquote>
<p>These commands will be ignored by IE/Mac. Such CSS hack is rather useful if some area of the site doesn’t work properly in IE/Mac. If it is something unimportant you can hide it from IE/Mac just like this:</p>
<blockquote><p>#noiemac {display: none}</p>
<p>/* Hide from IE-Mac \*/<br />
#noiemac {display: block}<br />
/* End hide */</p></blockquote>
<p>The first CSS rule hides the entire section assigned the noiemac id. The second CSS rule displays this section (can’t b seen by IE/Mac)</p>
<h3>Browser Detection for Netscape 4</h3>
<p>Netscape 4 has limited support for CSS. Thus, making a CSS layout for this browser can be quite a difficult task. Today most web developers prefer to hide the CSS file from this browser. You can do this with the <strong>@import</strong> directive to call up the CSS document:</p>
<blockquote><p>@import url(cssfile.css);</p></blockquote>
<p>Thus, Netscape 4 can&#8217;t understand this @import directive and will display a non-styled version of the site.</p>
<h3>Make Sure to Check Your Site in the Different Browsers</h3>
<p>This is a must. Just download the major browsers such as Firefox, IE5, IE6, Opera and Safari and check your site on PC and Mac. There are quite a lot of sites offering you their services in case you don’t have access to a Mac, so search for them.</p>
<p>The other main rule in case certain page elements appear differently in different browsers is stop worrying… and start making some trial-and-error changes playing with CSS rules. Anyway, you can fix it up with CSS hacks that always ready to help you make your site look great. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/cross-browser-css-hacks.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Hacks for… Everyone</title>
		<link>http://www.webdea.com/css-hacks.html</link>
		<comments>http://www.webdea.com/css-hacks.html#comments</comments>
		<pubDate>Thu, 28 Jan 2010 16:10:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css hacks]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[how to use]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[opera]]></category>

		<guid isPermaLink="false">http://www.webdea.com/?p=27</guid>
		<description><![CDATA[<a href="http://www.webdea.com/css-hacks.html"><img src="http://farm5.static.flickr.com/4013/4306190749_fd0534c29b_o.jpg" alt="CSS Hacks to know" align="left"></a>Here you can find all the necessary data concerning CSS hacks for Safari, Internet Explorer 7, Opera, etc., that sometimes really make problems. It is not so easy to remember them at once, so I write down several of them and offer you to use my “notes”. Hope that make your life easier… ]]></description>
			<content:encoded><![CDATA[<p>Today I want to talk about CSS hacks. <img src="http://farm5.static.flickr.com/4043/4306191275_970420d6da_o.jpg" alt="CSS Hacks to remember" align="right">There is no reason to explain why, because even with the release of Internet Explorer 8 we still need to use them. It seems that we will use them forever… especially with those clients who still prefer that damned IE6. </p>
<p>To remember all the CSS hacks seem to be impossible so I decide to create such a list that can be of use for you too. </p>
<p> So, let’s start. </p>
<h3>CSS for Internet Explorer:</h3>
<blockquote><p>/* for all versions */<br />
.class { *color: #8abdce; }</p></blockquote>
<p></br></p>
<blockquote><p>/* for Internet Explorer 6 */<br />
.class { _color: #8abdce; }<br />
or<br />
.class { -color: #8abdce; }</p></blockquote>
<p></br></p>
<blockquote><p>/* /* for Internet Explorer 7 */<br />
*+html .class { color: #8abdce; }</p></blockquote>
<p></br></p>
<blockquote><p>/* for Internet Explorer 7 */<br />
*:first-child+html .class { color: #8abdce; }</p></blockquote>
<p></br></p>
<blockquote><p>/* for Internet Explorer 7 */<br />
html>body .class {<br />
*background: #F00;<br />
}</p></blockquote>
<p></br></p>
<blockquote><p>/* for Internet Explorer 8 */<br />
.ie8only { color /*\**/: #fff\9 }</p></blockquote>
<p></br></p>
<h3>CSS Hacks for Opera:</h3>
<p><img src="http://farm5.static.flickr.com/4031/4306193131_20ce258a2b_o.jpg" alt="CSS Hacks for all" align="right"></p>
<blockquote><p>@media all and (-webkit-min-device-pixel-ratio:10000),<br />
not all and (-webkit-min-device-pixel-ratio:0) {<br />
.style {background: #F00;}<br />
}</p></blockquote>
<p></br></p>
<blockquote><p>html:first-child .class { color: #8abdce; }</p></blockquote>
<p></br></p>
<blockquote><p>*|html[xmlns*=""] .style {<br />
background: #F00;<br />
}</p></blockquote>
<p></br></p>
<h3>CSS Hacks for Firefox:</h3>
<blockquote><p>html:root .class { color: #8abdce; } /* this also works for Safari */</p></blockquote>
<p></br></p>
<blockquote><p>.class, x:-moz-any-link { color: #368EF1; }</p></blockquote>
<p></br></p>
<blockquote><p>@-moz-document url-prefix() {<br />
.style {color: #F00;}<br />
}</p></blockquote>
<p></br></p>
<blockquote><p>/* for FireFox 1-2 */<br />
@-moz-document url-prefix() {<br />
color: #F00;<br />
}</p></blockquote>
<p></br></p>
<h3>CSS Hacks for Safari:</h3>
<blockquote><p>html[xmlns*=""] body:last-child .class { color: #368EF1; }</p></blockquote>
<p></br></p>
<h3>CSS Hacks for Safari and Google Chrome:</h3>
<blockquote><p>body:last-child:not(:root:root) .style {<br />
color: #F00;<br />
}</p></blockquote>
<p></br></p>
<blockquote><p>body:nth-of-type(1) p {<br />
color: #333333;<br />
}</p></blockquote>
<p></br></p>
<p>Of course, hacks are evil, but sometimes they help to solve the problems. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdea.com/css-hacks.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

