<?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>ADM Blog &#187; CSS</title> <atom:link href="http://blog.another-d-mention.ro/tag/css/feed/" rel="self" type="application/rss+xml" /><link>http://blog.another-d-mention.ro</link> <description>No matter how you see things, reality changes when you reach understanding</description> <lastBuildDate>Fri, 22 Jul 2011 06:56:49 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1</generator> <item><title>Zen Coding</title><link>http://blog.another-d-mention.ro/misc/software/html-zen-coding/</link> <comments>http://blog.another-d-mention.ro/misc/software/html-zen-coding/#comments</comments> <pubDate>Tue, 11 May 2010 20:00:33 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Software]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[editor]]></category> <category><![CDATA[html]]></category> <category><![CDATA[xml]]></category> <category><![CDATA[zen]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=820</guid> <description><![CDATA[If you write HTML for a living, and you don't know Zen Coding yet, you are missing out big time. Zen Coding is build as a plugin for commonly used editors (including Notepad++, yey!) that allows you to write HTML, CSS and XML code 20 time faster. So writing: 1 html:xt&#62;div#header&#62;div#logo+ul#nav&#62;li.item-$*5&#62;a with a keystroke converts [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you write HTML for a living, and you don't know <a
href="http://code.google.com/p/zen-coding/">Zen Coding</a> yet, you are missing out big time.</p><p>Zen Coding is build as a plugin for commonly used editors (including Notepad++, yey!) that allows you to write HTML, CSS and XML code 20 time faster. So writing:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="java" style="font-family:monospace;">html<span style="color: #339933;">:</span>xt<span style="color: #339933;">&gt;</span>div#header<span style="color: #339933;">&gt;</span>div#logo<span style="color: #339933;">+</span>ul#nav<span style="color: #339933;">&gt;</span>li.<span style="color: #006633;">item</span><span style="color: #339933;">-</span>$<span style="color: #339933;">*</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">&gt;</span>a</pre></td></tr></table></div><p>with a keystroke converts to:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td
class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt; !DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;charset=UTF-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nav&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-1&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-2&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-3&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-4&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-5&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div><p>Don't get this wrong, like the man said, "The purpose of ZC is not to write a full HTML page with a single line, but to help you write smaller code chunks.". Here is a video introducing the system in further detail.</p><p><object
width="400" height="275"><param
name="allowfullscreen" value="true" /><param
name="allowscriptaccess" value="always" /><param
name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed
src="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="275"></embed></object></p><p>It is easier than it looks actually, and looking a bit over the <a
href="http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn">syntax</a> will make total sense. Printing the <a
href="http://code.google.com/p/zen-coding/downloads/detail?name=ZenCodingCheatSheet.pdf&#038;can=2&#038;q=">cheat sheet</a> also helps <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Zen Coding" class='wp-smiley' title="Zen Coding" /></p><p>Also worth noticing that in Notepad++ (the only one I tried) the plugin added few more functions that help with the coding that I'm sure you'll enjoy (Jumping to the edit points is a God given). This project inspired another neat tool for PHP developers to output HTML using this syntax from code. You can find more <a
href="http://code.google.com/p/zen-php/">here</a></p><p>I have only touched briefly on what it can do but I will certainly not author another single HTML document without the benefit of <a
href="http://code.google.com/p/zen-coding/">Zen Coding</a>.</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/misc/software/html-zen-coding/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Cheeky little tips that will help against email harvesting</title><link>http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/</link> <comments>http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/#comments</comments> <pubDate>Mon, 27 Jul 2009 11:52:01 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[email]]></category> <category><![CDATA[spam]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=534</guid> <description><![CDATA[Prevent email address harvesting, image downloading, and image theft by using CSS Pseudo Elements in conjunction with the Content property. This is a pure HTML/CSS solution to the problems of email harvesting and image theft with one common method. There is a little known feature of CSS called Pseudo Elements that allows for some special [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/xobni-makes-life-easier-really-it-does/' rel='bookmark' title='Permanent Link: Xobni Makes Life Easier. Really. It Does.'>Xobni Makes Life Easier. Really. It Does.</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/' rel='bookmark' title='Permanent Link: How To &#8211; get Cross Browser Compatibility Every Time'>How To &#8211; get Cross Browser Compatibility Every Time</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Prevent email address harvesting, image downloading, and image theft by using CSS Pseudo Elements in conjunction with the Content property. This is a pure HTML/CSS solution to the problems of email harvesting and image theft with one common method.</p><p>There is a little known feature of CSS called Pseudo Elements that allows for some special effects to be applied to elements. Using pseudo elements it is possible to add content before or after an element.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td
class="code"><pre class="html" style="font-family:monospace;">&lt;style type=&quot;text/css&quot;&gt;
	.demodiv{
    	     display:inherit;
	}
	.demodiv:before{
		content:&quot;myemail@example.com&quot;;
	}
&lt;/style&gt;
&nbsp;
&lt;div class=&quot;demodiv&quot;&gt;&amp;nbsp;&lt;/div&gt;</pre></td></tr></table></div><p>This will output: <strong>myemail@example.com</strong><br
/> You can also use as content <em>url('someimage.jpg');</em> to display images this way. A bit more detailed at <a
href="http://amatoc.com/content/show.php?id=21">amatoc.com</a></p><p>Another way to mask emails with css power:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="html" style="font-family:monospace;">&lt;style type=&quot;text/css&quot;&gt;
span.test {
     direction: rtl; unicode-bidi:bidi-override;
}
&lt;/style&gt;
&lt;span class=&quot;test&quot;&gt;moc.tset@tset&lt;/span&gt;</pre></td></tr></table></div><p>The CSS reverses the direction of the text, so you write your email backwards, the CSS sorts it out so it displays fine on your website, but this way, ’spam bots’ can’t read your email!</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/xobni-makes-life-easier-really-it-does/' rel='bookmark' title='Permanent Link: Xobni Makes Life Easier. Really. It Does.'>Xobni Makes Life Easier. Really. It Does.</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/' rel='bookmark' title='Permanent Link: How To &#8211; get Cross Browser Compatibility Every Time'>How To &#8211; get Cross Browser Compatibility Every Time</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Handy CSS Debug Snippet</title><link>http://blog.another-d-mention.ro/programming/handy-css-debug-snippet/</link> <comments>http://blog.another-d-mention.ro/programming/handy-css-debug-snippet/#comments</comments> <pubDate>Mon, 27 Jul 2009 10:46:21 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[debug]]></category> <category><![CDATA[html]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=530</guid> <description><![CDATA[Great little debuging snippet found while browsing. The code adds different coloured borders to the assets depending on its level. Leave commented out if not needed. 1 2 3 4 5 6 7 8 * &#123; outline: 2px dotted red &#125; * * &#123; outline: 2px dotted green &#125; * * * &#123; outline: 2px [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Great little debuging snippet found <a
href="http://homepage.mac.com/chrispage/iblog/C42511381/E20060806095030/index.html">while browsing</a>. The code adds different coloured borders to the assets depending on its level. Leave commented out if not needed.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">red</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">green</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">dotted</span> orange <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">dotted</span> <span style="color: #000000; font-weight: bold;">blue</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">red</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">green</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> orange <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">blue</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/handy-css-debug-snippet/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Cross browser inline-block</title><link>http://blog.another-d-mention.ro/programming/cross-browser-inline-block/</link> <comments>http://blog.another-d-mention.ro/programming/cross-browser-inline-block/#comments</comments> <pubDate>Thu, 26 Feb 2009 17:40:11 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[block]]></category> <category><![CDATA[browser]]></category> <category><![CDATA[fix]]></category> <category><![CDATA[inline]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=107</guid> <description><![CDATA[Ah, inline-block, that elusive and oh so tempting display declaration that promises so much, yet delivers so little. Too many times have I received PSD files like this: and begin to cry. Normally, this type of layout would be a cakewalk. Fixed width, fixed height, float:left and you’re done. Buuuuut, the design needs to work [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/' rel='bookmark' title='Permanent Link: How To &#8211; get Cross Browser Compatibility Every Time'>How To &#8211; get Cross Browser Compatibility Every Time</a></li><li><a
href='http://blog.another-d-mention.ro/misc/10-firefox-add-ons-for-web-designers/' rel='bookmark' title='Permanent Link: 10 Firefox add-ons for web designers'>10 Firefox add-ons for web designers</a></li><li><a
href='http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/' rel='bookmark' title='Permanent Link: Check if user visited certain websites'>Check if user visited certain websites</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Ah, inline-block, that elusive and oh so tempting display declaration that promises so much, yet delivers so little. Too many times have I received PSD files like this:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/gallery-view.jpg" alt="gallery view Cross browser inline block"  title="Cross browser inline block" /></p><p>and begin to cry.</p><p>Normally, this type of layout would be a cakewalk. Fixed width, fixed height, float:left and you’re done. Buuuuut, the design needs to work with variable amounts of content, which means if one of these blocks has more content than the others, it will break the layout:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/float-broken.jpg" alt="float broken Cross browser inline block"  title="Cross browser inline block" /></p><p>Because the first gallery item is taller than the rest, the 5th item is floated left against it instead of below it. Basically we want a layout with the flexibility of a table, but proper, semantic markup.</p><p>We start with a simple page with an unordered list and display set to inline-block:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td
class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
    &lt;li&gt;
        &lt;h4&gt;This is awesome&lt;/h4&gt;
        &lt;img src=&quot;http://farm4.static.flickr.com/3623/3279671785_d1f2e665b6_s.jpg&quot;
        alt=&quot;lobster&quot; width=&quot;75&quot; height=&quot;75&quot;/&gt;
    &lt;/li&gt;
...
&lt;/ul&gt;&lt;ul&gt;
&nbsp;
&lt;style&gt;
    li {
        width: 200px;
        min-height: 250px;
        border: 1px solid #000;
        display: inline-block;
        margin: 5px;
    }
&lt;/style&gt;
&lt;/ul&gt;</pre></td></tr></table></div><p>And it looks ok in Firefox 3, Safari 3 and Opera:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/step1.jpg" alt="step1 Cross browser inline block"  title="Cross browser inline block" /></p><p>Obviously, something is wrong with the vertical alignment. Well, not exactly wrong, because this is the correct behavior, but it’s not what we want.</p><p>What’s going on here is the baseline of each<li> is being aligned with the baseline of the parent < ul>. What’s a baseline, you ask? A picture is worth a thousand words:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/baseline.gif" alt="baseline Cross browser inline block"  title="Cross browser inline block" /></p><p>The baseline is the black line running through the text above. Putting it as simply as possible, the default vertical-align value on inline or inline-block element is baseline, which means the element’s baseline will be aligned with its parent’s baseline. Here’s the first inline-block attempt with baselines shown:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/baseline-inline-block.jpg" alt="baseline inline block Cross browser inline block"  title="Cross browser inline block" /></p><p>As you can see, each baseline is aligned with the baseline for the text ‘This is the baseline’. That text is not in a < /li>< li>, but simply a text node of the parent < ul>, to illustrate where the parent’s baseline is.</p><p>Anyway, the fix for this is simple: vertical-align:top, which results in a great looking grid:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/inline-block-2.jpg" alt="inline block 2 Cross browser inline block"  title="Cross browser inline block" /></p><p>Except it still doesn’t work in Firefox 2, IE 6 and 7.</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/inline-block-ff2.jpg" alt="inline block ff2 Cross browser inline block"  title="Cross browser inline block" /></p><p>Let’s start with Firefox 2.</p><p>Firefox 2 doesn’t support inline-block, but it does support a Mozilla specific display property ‘-moz-inline-stack’, which displays just like inline-block. And when we add it before display:inline-block, FF2 ignores that declaration and keeps -moz-inline-stack because it doesn’t support inline-block. Browsers that support inline-block will use it and ignore previous display property.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
    li <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-inline-stack<span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div><p>Unfortunately, it has a small bug:</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/inline-block-3.jpg" alt="inline block 3 Cross browser inline block"  title="Cross browser inline block" /></p><p>Honestly, I don’t know what causes this bug. But there is quick fix. Wrap everything inside the < li> with a < div>.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td
class="code"><pre class="html" style="font-family:monospace;">&lt;li&gt;
        &lt;div&gt;
            &lt;h4&gt;This is awesome&lt;/h4&gt;
            &lt;img src=&quot;http://farm4.static.flickr.com/3623/3279671785_d1f2e665b6_s.jpg&quot;
            alt=&quot;lobster&quot; width=&quot;75&quot; height=&quot;75&quot;/&gt;
        &lt;/div&gt;
&lt;/li&gt;</pre></td></tr></table></div><p>This seems to ‘reset’ everything inside the < li>’s and makes them display appropriately.</p><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/inline-block-2.jpg" alt="inline block 2 Cross browser inline block"  title="Cross browser inline block" /></p><p>Now, on to IE 7. IE 7 does not support inline-block, but we can trick it into rendering the < li>s as if they were inline-block. How? hasLayout, a magical property of IE that allows for all sorts of fun! You can’t set hasLayout explicity on an element with hasLayout:true; or anything easy like that, but you can trigger it with other declarations like zoom:1.</p><p>Technically, what hasLayout means is an element with hasLayout set to true is responsible for rendering itself and its children (combine that with a min-height and width, and you get something very similar to display:block). It’s kinda like magical fairy dust you can sprinkle on rendering issues and make them disappear.</p><p>When we add zoom:1 and *display:inline (star hack to target IE6 &#038; 7) to the < li>s, we make IE 7 display them as if they were inline-block:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
    li <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-inline-stack<span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
        zoom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div><p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/inline-block-ie7.jpg" alt="inline block ie7 Cross browser inline block"  title="Cross browser inline block" /></p><p>IE 6 doesn’t support min-height, but thanks to its improper handling of the height property, we can use that instead. Setting _height (IE6 underscore hack) to 250px will give all < li>s a height of 250px, and if their content is bigger than that, they will expand to fit. All other browsers will ignore _height.</p><p>So after all that work, here’s the final CSS and HTML:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
    li <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-inline-stack<span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
        zoom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
        _height<span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td
class="code"><pre class="html" style="font-family:monospace;">&lt;li&gt;
        &lt;div&gt;
            &lt;h4&gt;This is awesome&lt;/h4&gt;
            &lt;img src=&quot;http://farm4.static.flickr.com/3623/3279671785_d1f2e665b6_s.jpg&quot;
            alt=&quot;lobster&quot; width=&quot;75&quot; height=&quot;75&quot;/&gt;
        &lt;/div&gt;
&lt;/li&gt;</pre></td></tr></table></div></li><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/' rel='bookmark' title='Permanent Link: How To &#8211; get Cross Browser Compatibility Every Time'>How To &#8211; get Cross Browser Compatibility Every Time</a></li><li><a
href='http://blog.another-d-mention.ro/misc/10-firefox-add-ons-for-web-designers/' rel='bookmark' title='Permanent Link: 10 Firefox add-ons for web designers'>10 Firefox add-ons for web designers</a></li><li><a
href='http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/' rel='bookmark' title='Permanent Link: Check if user visited certain websites'>Check if user visited certain websites</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/cross-browser-inline-block/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>How To &#8211; get Cross Browser Compatibility Every Time</title><link>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/</link> <comments>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/#comments</comments> <pubDate>Fri, 20 Feb 2009 17:15:05 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[How To's]]></category> <category><![CDATA[chrome]]></category> <category><![CDATA[comaptibility]]></category> <category><![CDATA[firefox]]></category> <category><![CDATA[ie6]]></category> <category><![CDATA[ie7]]></category> <category><![CDATA[ie8]]></category> <category><![CDATA[opera]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=37</guid> <description><![CDATA[Working with Internet Explorer can be a pain for the everyday web designer. But it doesn't have to be. Many, if not all, of the bugs can be fixed quickly and easily by understanding how the occur. I've put together a list of the major problems beginners have with cross browser compatibility. I'm only going [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/' rel='bookmark' title='Permanent Link: Cheeky little tips that will help against email harvesting'>Cheeky little tips that will help against email harvesting</a></li><li><a
href='http://blog.another-d-mention.ro/programming/use-any-font-with-cufon/' rel='bookmark' title='Permanent Link: Use any Font with Cufon'>Use any Font with Cufon</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Working with Internet Explorer can be a pain for the everyday web designer. But it doesn't have to be. Many, if not all, of the bugs can be fixed quickly and easily by understanding how the occur. I've put together a list of the major problems beginners have with cross browser compatibility.</p><p>I'm only going to be concerned with the major browsers - Firefox 2+, Safari 3+ and Internet Explorer 6+. IE6 is slowly declining.  If you know the IE6 bugs you can generally know if your site will break before you even check it in a browser. This isn't an article for the super-experienced web designer, but hopefully will give some insight to some people who don't understand the mysteries of IE6 and cross browser compatibility.</p><h2>Summary</h2><p>Here is a quick summary for those of you who don't want to read the whole article:</p><ul><li>Always use strict doctype and standards-compliant HTML/CSS</li><li>Always use a reset at the start of your css</li><li>Use -moz-opacity:0.99 on text elements to clean up rendering in Firefox, and text-shadow: #000 0 0 0 in Safari</li><li>Never resize images in the CSS or HTML</li><li>Check font rendering in every browser. Don't use Lucida</li><li>Size text as a % in the body, and as em's throughout</li><li>All layout divs that are floated should include display:inline and overflow:hidden</li><li> Containers should have overflow:auto and trigger hasLayout via a width or height</li><li>Don't use any fancy CSS3 selectors</li><li>Don't use transparent PNG's unless you have loaded the alpha</li></ul><h2>Element Inconsistencies</h2><p>Every browser renders particular elements differently - different amounts of padding, margins, borders etc. This means your site can look different in every browser if you use default styles.</p><p><strong>Solution</strong></p><p>The first thing you should do, which most people most likely know about, is to reset your styles. A reset is some css you place at the start of your styles that removes the padding, margin, border and other inconsistencies from elements, and rebuilds them in a standard way.</p><p>Download Eric Meyer's <a
href="http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/">reset.css</a> and place the code at the start of your styles. Bam! Clean, cross browser styles.</p><h2>Image Rendering</h2><p>IE6 and IE7 both render resized images extremely badly. When you change the size of an image with CSS or in the HTML, it appears blocky and edgy.<br
/> <strong>Solution</strong></p><p>Don't do it. Always size your images to your desired size before you use them on your site</p><h2>Font Rendering</h2><p>I told you not all issues were with IE. Safari 3+ has an issue with the way it renders light type on a dark background. Some would argue whether this is good or bad, but there's a way to make it appear lighter. Here's an example of standard white on black text rendering in Safari 3.1:</p><p><img
class="alignnone size-full wp-image-38" style="border: 1px solid black; padding: 3px;" title="safari-before" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-before.png" alt="safari before How To   get Cross Browser Compatibility Every Time" width="351" height="165" /></p><p><strong>Solution</strong><br
/> Easy fix. You need to add this to your code.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Where #000 is your background colour. You will probably have to be more specific with the elements you select. I wouldn't suggest using this fix on the body tag. Other elements you might need to fix are the li, dt, dd, blockquote etc. Use this on any text element you want to appear 'thinner'</p><p>To make this fix in Firefox, you use the opacity fix:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
    -moz-opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.99</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>You need to be careful with this fix, as it will break any Flash element that it touches in Firefox. There appears to be no workaround for it.</p><p>The type will now be rendered like this:</p><p><img
class="alignnone size-full wp-image-46" style="border: 1px solid black; padding: 3px;" title="safari-after" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-after.png" alt="safari after How To   get Cross Browser Compatibility Every Time" width="336" height="157" /></p><h2>Font Selection</h2><p>There are common web fonts that we use - Arial, Georgia, Verdana etc. But there are some fonts that are common to both PC and Mac and can be used - Century Gothic, Arial Narrow etc. However, different browsers and OS's render type different, and you need to be aware of these differences, as your site could look dam ugly if you use the wrong font.</p><p><strong>Solution</strong></p><p>The font you choose is ultimately up to you. As long as it's a safe font you will be fine. However you should be aware of these rendering issues. One font you should probably not use is Lucida Grande/Sans. It renders awful in IE. Take a look at its rendering in Safari(Mac):</p><p><img
class="alignnone size-full wp-image-47" style="border: 1px solid black; padding: 3px;" title="safari-lucida" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-lucida.png" alt="safari lucida How To   get Cross Browser Compatibility Every Time" width="600" height="120" /></p><p>Looks nice doesn't it? Too bad it looks like this in Internet Explorer(PC):</p><p><img
class="alignnone size-full wp-image-48" style="border: 1px solid black; padding: 3px;" title="ie6-lucida" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/ie6-lucida.png" alt="ie6 lucida How To   get Cross Browser Compatibility Every Time" width="600" height="120" /></p><p>Some people have stated that Lucida Sans will look fine in IE with ClearType, and others have said that it still looks bad. A smart alternative is to just not use Lucida Sans as your 'fallback font', and instead use Arial or another san-serif font.</p><h2>Font Sizing</h2><p>The ability to resize text differs amongst browsers and OS's. IE won't resize text thats set in pixels. If we set all text in em's, IE will exaggerate the text sizes when resized.</p><p><strong>Solution</strong></p><p>The best reference for font sizing is the article <a
href="http://www.alistapart.com/articles/howtosizetextincss">How to Size Type in CSS</a> by Richard Rutter. The results - You need to specify the size as a percentage in the body element, and then size it in em's through the rest of the sheet. For line height, you need to define it in em's, rather than pixels, for consistent rendering.<br
/> One thing to remember is that the default font size is 16px. So to resize our type to 12px we use:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75%</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Now you can size your type in em's like so:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">h1<span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Another suggested technique is to resize it down to 10px, which makes it easier to size upwards in em's. For example.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">62.5%</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.8em</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* 18px */</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
p <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* 12px */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>here is an issue with this however, if people use small font option in Internet Explorer, it could be so small that it's unreadable. It's only a small chance. But worth noting.</p><h2>Double Margins on Floats</h2><p>We create CSS layouts by floating div's up against each other, like some form of horizontal tetris. When it reaches the end of a row, it drops down to the next. The common method for creating a grid is this:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>This is what it should look like in a browser:</p><p><img
class="alignnone size-medium wp-image-58" style="border: 1px solid black; padding: 3px;" title="doublemargin-ff" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/doublemargin-ff-300x264.png" alt="doublemargin ff 300x264 How To   get Cross Browser Compatibility Every Time" width="300" height="264" /></p><p>This is what IE does to it:</p><p><img
class="alignnone size-full wp-image-59" style="border: 1px solid black; padding: 3px;" title="doublemargin-ie" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/doublemargin-ie.png" alt="doublemargin ie How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>The margin width is doubled. Any margin that is on the same side as the float will be doubled. Don't ask why. It's just IE. This means the element on the left will have that margin stretched out to 20px, which will probably break the layout.</p><p><strong>Solution</strong></p><p>To fix it, all you need to do is put display:inline on your layout divs.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Now that margin bug is all fixed. Even though it only effects margins on the same side as the float, it can still be useful to include this fix. You never know when you might use a margin on the float side. It won't effect any other browser, so you can use it safely.</p><h2>Expanding Box</h2><p>The expanding box problem is a big issue with many css layouts. When you have a standard layout, with floats sitting next to each other, with set widths, but an image or long string of text is longer than this width, the layout will break in IE6. Take a look at this example:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>This will render like in this most browsers:</p><p><img
class="alignnone size-full wp-image-63" style="border: 1px solid black; padding: 3px;" title="expandingbox" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/expandingbox.png" alt="expandingbox How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>However, in IE6, it will break like so:</p><p><img
class="alignnone size-full wp-image-64" style="border: 1px solid black; padding: 3px;" title="expandingbox-ie" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/expandingbox-ie.png" alt="expandingbox ie How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p><strong>Solution</strong></p><p>The solution is to use the overflow property. If you place overflow:hidden; into the layout divs, the layout won't break in IE6.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>This could, however, cause some issues with layouts depending on how complex they are. It also won't cause the text to wrap, and it will just remain hidden. It's unlikely you'll have a string long enough to break a layout, but it could happen. Another option is to use word-wrap: break-word; in an IE specific stylesheet. This won't effect images though, so you'll have to make a choice about with method is appropriate for your situation.</p><h2>Clearing Floats</h2><p>What we mean when we talk about clearing floats, is when a container or wrapper div doesn't correctly wrap around the containing divs. Take a look at this example:</p><p><img
class="alignnone size-full wp-image-66" style="border: 1px solid black; padding: 3px;" title="clearing" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/clearing.png" alt="clearing How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>See how the container is correctly containing the div's? This is what should happen. However, sometimes it does not clear correctly, like so:</p><p><img
class="alignnone size-full wp-image-67" style="border: 1px solid black; padding: 3px;" title="noclearing" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/noclearing.png" alt="noclearing How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>The container isn't correctly wrapping around it. You probably won't notice this until you try and put a background on your container.</p><p><strong>Solution</strong></p><p>There are a few different solutions for clearing. The best solution however, is a simple <strong>overflow:auto</strong> or <strong>overflow:hidden</strong> in your container</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">966px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>You need to keep in mind that overflow:auto might cause some issues in Firefox. If you do have any issues, use overflow:hidden instead. If this is still causing issues, take a look at <a
href="http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/">some other forms of clearing floats</a>. Apart from just adding this, you'll need to make sure hasLayout is triggered in IE6. You can do this by specifying a width or height. If you don't have a width in your container, you can use height:1% to trigger it, or zoom:1; if you can't afford to give it a height.</p><h2>CSS Selectors</h2><p>Although we would like to use all the brand spanking new CSS3 selectors, IE6 doesn't support all of the major ones. There are also still some CSS2 child and sibling selectors you simply shouldn't use if you want to support IE6:</p><ul><li>E &gt; F</li><li>E + F</li><li>E ~ F</li><li>:root</li><li>:last-child</li><li> <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_surprised.gif' alt="icon surprised How To   get Cross Browser Compatibility Every Time" class='wp-smiley' title="How To   get Cross Browser Compatibility Every Time" /> nly-child</li><li>:nth-child()</li><li>:nth-last-child()</li><li>:first-of-type</li><li>:last-of-type</li><li> <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_surprised.gif' alt="icon surprised How To   get Cross Browser Compatibility Every Time" class='wp-smiley' title="How To   get Cross Browser Compatibility Every Time" /> nly-of-type</li><li>:nth-of-type()</li><li>:nth-last-of-type()</li><li>:empty</li><li>:not()</li><li>:target</li><li>:enable</li><li>:disabled</li><li>:checked</li><li>Any of the E[attribute] Selectors</li><li>:first-child</li><li>:lang()</li><li>:before</li><li>::before</li><li>:after</li><li>::after</li></ul><p>f course, a lot of these selectors aren't supported by even Firefox 3. For a full list of supported selectors, check out evotech.net's post on <a
href="http://www.evotech.net/blog/2008/05/browser-css-selector-support/">browser css selector support</a></p><p><strong>Solution</strong></p><p>Stick to your standard selectors. Nothing fancy. Only use E + F, E &gt; F, E ~ F when it won't make a huge difference in IE. If you really need to use these selectors, you should look at using IE8.js which gives IE6 better selector support. However this will slow down your site. But we don't really care about IE6 users do we?</p><h2>PNG Transparency</h2><p>IE6 doesn't support alpha transparency in PNG's. This is possibly the most annoying bug/issue with IE.</p><p><strong>Solution</strong></p><p>There are a few solutions for this problem. You can either use AlphaImageLoader in an IE specific stylesheet, link to a behaviour file in an IE specific stylesheet or use JS to fix the issue. Not matter which way you choose, there is no way to have transparent repeating background images.<br
/> To use AlphaImageLoader, it's a little bit tricky. Add these properties to any png image you want to have transparency. (You need to put this code in an IE specific stylesheet if you want your CSS to validate)</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.trans</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
     filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.AlphaImageLoader<span style="color: #00AA00;">&#40;</span>src<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'/images/transparent.png'</span><span style="color: #00AA00;">,</span> sizingMethod<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'image/scale/crop'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Let's say you've given all your png image tags a class "trans", you select them with your css and use the filter property. You need to create a 1x1 transparent png file and link to it in the src attribute.</p><p>An even better way to do this is via a behaviour. It's similar to the AlphaImageLoader, except that you link to a behaviour script that triggers the transparency.</p><p>The third method is to use IE8.js which I mentioned earlier. It's even safer than the previous method, and you are very unlikely to run into any problems. Link to the script in your HTML, and it will make any png ending in -trans alpha-capable. eg. myimage-trans.png.</p><p><strong>With all this methods, you need to be aware that you might still run into problems with transparent pngs. Make sure you test it in IE6 extensively</strong></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/' rel='bookmark' title='Permanent Link: Cheeky little tips that will help against email harvesting'>Cheeky little tips that will help against email harvesting</a></li><li><a
href='http://blog.another-d-mention.ro/programming/use-any-font-with-cufon/' rel='bookmark' title='Permanent Link: Use any Font with Cufon'>Use any Font with Cufon</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
