<?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>maratz.com &#187; CSS 101</title>
	<atom:link href="http://www.maratz.com/blog/archives/category/css-101/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maratz.com/blog</link>
	<description>Hypertext rulez™</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Remove HTML line breaks for mobile devices with @media query</title>
		<link>http://www.maratz.com/blog/archives/2011/02/21/remove-html-line-breaks-for-mobile-devices-with-media-query/</link>
		<comments>http://www.maratz.com/blog/archives/2011/02/21/remove-html-line-breaks-for-mobile-devices-with-media-query/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 16:26:41 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=1571</guid>
		<description><![CDATA[The old school way of setting large (intro) texts on web pages involved some kind of CSS image replacement, enabling a fine-grained control over how type and text render. Now that we have web fonts available, we can avoid image replacement and apply virtually any font to a plain HTML with a little help of [...]]]></description>
			<content:encoded><![CDATA[<p>The old school way of setting large (intro) texts on web pages involved some kind of CSS image replacement, enabling a fine-grained control over how type and text render.</p>
<p>Now that we have web fonts available, we can avoid image replacement and apply virtually any font to a plain HTML with a little help of <a href="http://www.font-face.com/">@font-face rule</a>. </p>
<p>Another problem with HTML text is how lines of text break. If you aim to create a particular rhythm to your copy, you’d probably want to control the length of each line. Naturally, you can <a href="http://www.w3.org/TR/html401/struct/text.html#h-9.3.2">use <code>&#60;br /&#62;</code> to push the text into another line</a>. </p>
<p>However, to enable natural flow of text on mobile screens which are narrower than the desktop horizontal text block offset, you simply add <a href="http://www.w3.org/TR/css3-mediaqueries/">@media query</a> to your CSS:</p>
<p><code>
<pre>
@media (max-width: 480px) {
    .your-particular-selector br { display:  none; }
}
</pre>
<p></code></p>
<p>Please note that you should leave an extra space behind each <code>&#60;br /&#62;</code>. This way when it’s removed with CSS for mobile devices, you won’t end up with weird results, for instance <code>Lorem ipsumdolor sit amet,consectetur</code>:</p>
<p><code>
<pre>
Lorem ipsum&#60;br /&#62; dolor sit amet,&#60;br /&#62; consectetur...
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2011/02/21/remove-html-line-breaks-for-mobile-devices-with-media-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fix HTML resized images in Internet Explorer</title>
		<link>http://www.maratz.com/blog/archives/2010/07/06/fix-html-resized-images-in-internet-explorer/</link>
		<comments>http://www.maratz.com/blog/archives/2010/07/06/fix-html-resized-images-in-internet-explorer/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 07:45:47 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=1303</guid>
		<description><![CDATA[HTML resized images in Internet Explorer look like crap, unless you add the following line in IE-speciffic CSS: img { -ms-interpolation-mode: bicubic; } Handle with care.]]></description>
			<content:encoded><![CDATA[<p>HTML resized images in Internet Explorer look like crap, unless you add the following line in <a href="/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/">IE-speciffic CSS</a>:</p>
<p><code>
<pre>img { -ms-interpolation-mode: bicubic; }</pre>
<p></code></p>
<p>Handle with care.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2010/07/06/fix-html-resized-images-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>First look at the CSS support in Internet Explorer 8</title>
		<link>http://www.maratz.com/blog/archives/2009/03/22/first-look-at-the-css-support-in-internet-explorer-8/</link>
		<comments>http://www.maratz.com/blog/archives/2009/03/22/first-look-at-the-css-support-in-internet-explorer-8/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 14:53:23 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=844</guid>
		<description><![CDATA[Internet Explorer 8 is released last week. The IE team promised the browser will be more standards aware, similar to it&#8217;s major competition Firefox, Opera and Safari. The trouble is — designers and developers don&#8217;t settle for current minimum, we are always into something new. So, by the time a giant vendor locks the feature [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoft.com/windows/internet-explorer/">Internet Explorer 8</a> is released last week. The IE team promised the browser will be more standards aware, similar to it&#8217;s major competition <a href="http://www.mozilla.org/firefox">Firefox</a>, <a href="http://www.opera.com/">Opera</a> and <a href="http://www.apple.com/safari">Safari</a>.</p>
<p>The trouble is — designers and developers don&#8217;t settle for current minimum, we are always into something new. So, by the time a giant vendor locks the feature list, a more flexible and agile competition goes miles away.</p>
<p>In the era of rounded corners/borders and transparency made possible purely with CSS, IE team missed to implement both, or at least in the form that wouldn&#8217;t require separate style-sheets files to conform to <a href="http://www.w3.org/">W3C</a> guidelines.</p>
<p>I checked a few dozens of CSS-based web sites, and I&#8217;m not even sure anymore if everything works because developers payed special attention to IE 6 and IE 7, or is it because IE 8 is mature enough to render CSS layouts properly.</p>
<h2>What works, what isn&#8217;t working</h2>
<p>PNGs work without hacking. Rounded corners with CSS not. Text shadow — no. Alpha transparency is still possible only with proprietary filter property, for instance <code>filter: alpha(opacity=10);</code>.</p>
<p>Naturally, if you want your CSS to validate — this rule has to be extracted in separate file, <a href="/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/">preferably with conditional comments</a>.</p>
<p>The old <a href="http://www.maratz.com/blog/archives/2006/10/23/ie-7-quirks-round-one/">typeface order bug</a> is still present, and easy font embedding with <code>@font-face</code> doesn&#8217;t work either, so if you prefer this method, read <a href="http://jontangerine.com/log/2008/10/font-face-in-ie-making-web-fonts-work">how to do it in IE</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2009/03/22/first-look-at-the-css-support-in-internet-explorer-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Episode Four: Create bullet-proof, eco-friendly CSS</title>
		<link>http://www.maratz.com/blog/archives/2008/12/18/episode-four-create-bullet-proof-eco-friendly-css/</link>
		<comments>http://www.maratz.com/blog/archives/2008/12/18/episode-four-create-bullet-proof-eco-friendly-css/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 09:07:29 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=807</guid>
		<description><![CDATA[This is the fourth part of the series, “Environmental friendly CSS” In the previous episodes we’ve created a creative/technical brief, mocked-up design in Photoshop and decided on proper markup for the category cloud. Finally, we turn our design into web page element with some nifty CSS. For those of you who better understand from live [...]]]></description>
			<content:encoded><![CDATA[<div class="alignleft-pull pullquote">
<p>This is the fourth part of the series, “<a href="http://www.maratz.com/blog/archives/2008/11/23/environmental-friendly-css-the-series/">Environmental friendly CSS</a>”</p>
</div>
<p>In the previous episodes we’ve <a href="http://www.maratz.com/blog/archives/2008/11/27/episode-one-prepare-your-content-and-interface-copy/">created a creative/technical brief</a>, <a href="http://www.maratz.com/blog/archives/2008/12/04/episode-two-visually-design-information-elements-and-user-interface/">mocked-up design</a> in Photoshop and decided on <a href="http://www.maratz.com/blog/archives/2008/12/11/episode-three-mark-it-up/">proper markup for the category cloud</a>. Finally, we turn our design into web page element with some nifty CSS.</p>
<p>For those of you who better understand from live examples, here&#8217;s a <a href="http://webdesign.maratz.com/lab/environmental-friendly-css/">little treat for you</a>. If you&#8217;re beginner in CSS, read on. <span id="more-807"></span></p>
<h2>From the outside to the inside</h2>
<p>It is common sense to most of us, but nevertheless here&#8217;s an advice — don&#8217;t get into details too early, because you will have to go forth and back in the code too often.</p>
<p>Let&#8217;s pull the markup on stage:</p>
<p><code>
<pre>&#60;div id="categories"&#62;
	&#60;h4&#62;Most popular joke types and categories&#60;/h4&#62;
	&#60;ul&#62;
		&#60;li&#62;&#60;a href="#"&#62;Political jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Professional humor&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Mathematical jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Ethnic jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;British tell jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Self-deprecating humor&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Blonde jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Redneck jokes&#60;/a&#62;&#60;/li&#62;
	&#60;/ul&#62;
&#60;/div&#62;</pre>
<p></code></p>
<p>First set-up the main frame: set the dimensions and positioning of the <code>&#60;div id="categories"&#62;</code>. The width is fixed, but we let the height stay flexible, so if more content gets in there in the future, the box won&#8217;t break.</p>
<p>If you haven&#8217;t done so yet, <a href="http://www.maratz.com/downloads/environmental-friendly-css/environmental-friendly-css.psd.zip">Download .PSD file</a> and open it with Photoshop.</p>
<p>The rounded box has a width of 300px, so here the CSS goes:</p>
<p><code>
<pre>#categories { width: 300px; }</pre>
<p></code></p>
<p>The area below links to the bottom of the lowest character shadow is approximatelly 275px high. We add bottom padding, so there is always plenty of room for the comic dialog, no matter how many links is displayed:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
}</pre>
<p></code></p>
<p>Next, slice the top part of the box, name it <code>box-top.gif</code> and Save it in the same folder where the CSS file resides. It should look something like this:</p>
<p><img src="/img/2008/12-dec/18/01.gif" alt="" width="300" height="20" /></p>
<p>Now add background to the box:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
}</pre>
<p></code></p>
<h2>Detail 1: the heading</h2>
<p>We are not going to use the copy in the markup. Instead, there is a dialog bubble which is supposed to do the communication.</p>
<p>You&#8217;ve noticed that the bubble (i.e. <code>h4</code>) is off-set to the right. We have also set fixed width to <code>&#60;div id="categories"&#62;</code>. With <code>position: absolute</code> we&#8217;re going to shift the bubble outside the box. It will not break layout because absolute positioned elements are out of the document flow, which means they don&#8217;t affect their surrounding elements.</p>
<p>We already made some room for the dialog with bottom padding. Now we only have to add one more rule to <code>&#60;div id="categories"&#62;</code> so we can position <code>h4</code> relatively to the container:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}</pre>
<p></code></p>
<p>Remember, we left 275 pixels in height, so we use it to dimension the <code>h4</code>. Width is set to 100% by default, since <code>h4</code> is a block level element, but we need to push it outside the box, so we also need to increase its default with from 300 pixels (100%) to 350 pixels.</p>
<p>Finally, we use <code>bottom</code> and <code>left</code> CSS properties to set coordinates.</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
}
</pre>
<p></code></p>
<p>Now, go back to Photoshop and slice the bottom of the box and the dialog. You should get 350 x 275 pixels .GIF. Name it — you guessed it — <code>box-bottom.gif</code> and Save it in the same folder where the CSS file resides:</p>
<p><img src="/img/2008/12-dec/18/02.gif" alt="" width="350" height="275" /></p>
<p>Add background to CSS:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
}
</pre>
<p></code></p>
<p>And shift the remaining text to the left, by <code>text-indent</code>:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
    text-indent: -9999px;
    overflow: hidden; /* with this rule
        the container doesn't stretch to the left */
}
</pre>
<p></code></p>
<p>So far, so good: only the category links have been left to be done.</p>
<h2>Detail 2: list of categories</h2>
<p>At the beginning of the list styling, remove bullets and the default display behavior:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
    text-indent: -9999px;
    overflow: hidden; /* with this rule
        the container doesn't stretch to the left */
}

#categories li {
    list-style: none;
    display: inline;
}
</pre>
<p></code></p>
<p>Then we tell text to go into center, add some padding to <code>ul</code> element and remove possibly inherited margins:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
    text-indent: -9999px;
    overflow: hidden; /* with this rule
        the container doesn't stretch to the left */
}

#categories ul {
    text-align: center;
    padding: 1em 1.5em;
    margin: 0;
}

#categories li {
    list-style: none;
    display: inline;
}
</pre>
<p></code></p>
<p>And FINALLY add Comic Sans font to links:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
    text-indent: -9999px;
    overflow: hidden; /* with this rule
        the container doesn't stretch to the left */
}

#categories ul {
    text-align: center;
    padding: 1em 1.5em;
    margin: 0;
}

#categories li {
    list-style: none;
    display: inline;
}

#categories li a {
    font-family: 'Comic Sans MS', sans-serif;
    text-decoration: none;
    color: #fff;
}
</pre>
<p></code></p>
<p>Links are now perhaps too crowded, so we tweak them with some right and left padding. Also don&#8217;t forget <code>:hover</code> and <code>:focus</code> states:</p>
<p><code>
<pre>#categories {
    width: 300px;
    padding-bottom: 275px;
    background: #000 url(box-top.gif) no-repeat 0 0;
    position: relative;
}

#categories h4 {
    position: absolute;
    height: 275px;
    width: 350px;
    left: 0;
    bottom: 0;
    background: url(box-bottom.gif);
    text-indent: -9999px;
    overflow: hidden; /* with this rule
        the container doesn't stretch to the left */
}

#categories ul {
    text-align: center;
    padding: 1em 1.5em;
    margin: 0;
}

#categories li {
    list-style: none;
    display: inline;
}

#categories li a {
    font-family: 'Comic Sans MS', sans-serif;
    text-decoration: none;
    color: #fff;
    padding: 0 .2em;
        /* equals to 2px if calculated font-size is 10px */
}

#categories li a:hover,
#categories li a:focus {
    text-decoration: underline;
}
</pre>
<p></code></p>
<p>Excellent! Here is <strong>the final <a href="http://webdesign.maratz.com/lab/environmental-friendly-css/">working example</a></strong>. Go ahead, resize the text in your browser, or add more items — it won&#8217;t break. Everything is done except&#8230;</p>
<h2>Different font sizes?</h2>
<p>We miss one more thing — the different font sizes. But, it&#8217;s not done in CSS file, but with some inline HTML attributes. Basically, it all comes down to two approaches:</p>
<ul>
<li>a set of distinctive class names or</li>
<li>inline styles.</li>
</ul>
<p>Either way, you&#8217;ll have to do it server side or with JavaScript (both methods coming-up early in 2009.).</p>
<h2>What have we learned?</h2>
<p><strong>With lean markup, but smart CSS, almost any design can be sliced to a high quality web interface.</strong> Not only that — we also managed to make it bullet-proof, so the various scenarios (text resize and different amounts of content) don&#8217;t break the layout.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2008/12/18/episode-four-create-bullet-proof-eco-friendly-css/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Episode Three: Mark it up!</title>
		<link>http://www.maratz.com/blog/archives/2008/12/11/episode-three-mark-it-up/</link>
		<comments>http://www.maratz.com/blog/archives/2008/12/11/episode-three-mark-it-up/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 11:54:21 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=792</guid>
		<description><![CDATA[This is the third part of the series, “Environmental friendly CSS” In the previous episodes we’ve created a creative/technical brief and then mocked-up design in Photoshop. The next step in a process is creating solid XHTML markup. Let&#8217;s open it up with a question: How to markup category cloud? There are two simple approaches that [...]]]></description>
			<content:encoded><![CDATA[<div class="alignleft-pull pullquote">
<p>This is the third part of the series, “<a href="http://www.maratz.com/blog/archives/2008/11/23/environmental-friendly-css-the-series/">Environmental friendly CSS</a>”</p>
</div>
<p>In the previous episodes we’ve <a href="http://www.maratz.com/blog/archives/2008/11/27/episode-one-prepare-your-content-and-interface-copy/">created a creative/technical brief</a> and then <a href="http://www.maratz.com/blog/archives/2008/12/04/episode-two-visually-design-information-elements-and-user-interface/">mocked-up design</a> in Photoshop. The next step in a process is creating solid XHTML markup. Let&#8217;s open it up with a question:</p>
<h2>How to markup category cloud?</h2>
<p>There are two simple approaches that usually comes to mind at first: a paragraph and an unordered list.</p>
<p>If we use paragraph with links, we wouldn&#8217;t probably miss it in terms of the default presentation across the range of User Agents. The thing is — if one is marking-up a &#8216;cloud&#8217;, it&#8217;s natural that all the links are inline, one after another.</p>
<blockquote><p>— Let me think about it! Yea, I will just set <code>text-alignment: center</code> to that paragraph and I&#8217;m done. Great!</p></blockquote>
<p><span id="more-792"></span></p>
<div><code>
<pre>&#60;div id="category-cloud"&#62;
	&#60;h4&#62;Most popular joke types and categories&#60;/h4&#62;
	&#60;p&#62;
		&#60;a href="#"&#62;Political jokes&#60;/a&#62;
		&#60;a href="#"&#62;Professional humor&#60;/a&#62;
		&#60;a href="#"&#62;Mathematical jokes&#60;/a&#62;
		&#60;a href="#"&#62;Ethnic jokes&#60;/a&#62;
		&#60;a href="#"&#62;British tell jokes&#60;/a&#62;
		&#60;a href="#"&#62;Self-deprecating humor&#60;/a&#62;
		&#60;a href="#"&#62;Blonde jokes&#60;/a&#62;
		&#60;a href="#"&#62;Redneck jokes&#60;/a&#62;
	&#60;/p&#62;
&#60;/div&#62;</pre>
<p></code></div>
<p><strong>Not great!</strong> The above code is wrong. The &#8216;cloud&#8217; is a visual cue, not the structural element. The category cloud is — in its essence — a list of categories, so the more suitable XHTML element would be unordered list.</p>
<h2>It&#8217;s not a cloud, it&#8217;s a list</h2>
<p>Cloud as typography or XHTML element doesn&#8217;t exist. Tag or category <strong>cloud is a visual representation  of the list</strong> of categories. So let&#8217;s try semantically correct markup — an unordered list.</p>
<div><code>
<pre>&#60;div id="categories"&#62;
	&#60;h4&#62;Most popular joke types and categories&#60;/h4&#62;
	&#60;ul&#62;
		&#60;li&#62;&#60;a href="#"&#62;Political jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Professional humor&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Mathematical jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Ethnic jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;British tell jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Self-deprecating humor&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Blonde jokes&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;&#60;a href="#"&#62;Redneck jokes&#60;/a&#62;&#60;/li&#62;
	&#60;/ul&#62;
&#60;/div&#62;</pre>
<p></code></div>
<p>Some novice CSS developers in the past argued that they were having troubles with list-items in tag clouds. In the last article (coming up next week) we will explain it throughout. But, it&#8217;s very important to <strong>learn how to shift from visual/CSS mindset to semantic/contextual XHTML mindset</strong>.</p>
<h2>A little practice will get you there</h2>
<p>When deciding on the XHTML structure for any given element, <strong>try to ignore the design at first</strong>. You will easily modify markup later if you find no other way to accomplish layout only with CSS.</p>
<p>Instead, dive-in under the surface and check the bare-naked content and context to decide what markup should do the job.</p>
<p>If creating XHTML snippets is a second nature to you, please share how do <em>you</em> <strong>fight your thoughts about how it&#8217;s going to look</strong> when choosing appropriate markup?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2008/12/11/episode-three-mark-it-up/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Environmental friendly CSS, the series</title>
		<link>http://www.maratz.com/blog/archives/2008/11/23/environmental-friendly-css-the-series/</link>
		<comments>http://www.maratz.com/blog/archives/2008/11/23/environmental-friendly-css-the-series/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 11:14:38 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=719</guid>
		<description><![CDATA[Anything is recyclable, so is your HTML markup. Claim the right to do it with nature-, eco-, environmental-friendly style sheets! (use whichever buzzword). Buckle up, ‘cause we are introducing Environmental friendly CSS, a four article series, that aims to shift any novice and CSS expert alike — into ecologically aware client-side developer. The series is [...]]]></description>
			<content:encoded><![CDATA[<p>Anything is recyclable, so is your HTML markup. Claim the right to do it with nature-, eco-, environmental-friendly style sheets! (use whichever buzzword).</p>
<p>Buckle up, ‘cause we are introducing <strong>Environmental friendly CSS</strong>, a four article series, that aims to shift any novice and CSS expert alike — into ecologically aware client-side developer. The series is based on a real-world web site, developed as we speak.</p>
<p><img src="http://www.maratz.com/img/2008/11-nov/environmental-friendly-css.jpg" alt="" /></p>
<p>The first article is expected this Thursday morning CET, and the others over the next three weeks. Here is the series overview:</p>
<ol>
<li>
<dl>
<dt><a href="http://www.maratz.com/blog/archives/2008/11/27/episode-one-prepare-your-content-and-interface-copy/">Prepare your content and interface copy</a></dt>
<dd>Think about the context, the content, the real users, accessibility and search engines.</dd>
</dl>
</li>
<li>
<dl>
<dt><a href="http://www.maratz.com/blog/archives/2008/12/04/episode-two-visually-design-information-elements-and-user-interface/">Visually design information elements and user interface</a></dt>
<dd>Go wild in your graphic editor to lead the eyes around the layout.</dd>
</dl>
</li>
<li>
<dl>
<dt><a href="http://www.maratz.com/blog/archives/2008/12/11/episode-three-mark-it-up/">Mark it up!</a></dt>
<dd>Create sound and solid markup, with accessibility in mind — without looking into the visual mockup.</dd>
</dl>
</li>
<li>
<dl>
<dt><a href="http://www.maratz.com/blog/archives/2008/12/18/episode-four-create-bullet-proof-eco-friendly-css/">Create bullet-proof, eco-friendly CSS</a></dt>
<dd>Use CSS skills to recycle accessibility-related markup into visually attractive hints.</dd>
</dl>
</li>
</ol>
<p>For all the fans out there: we are going to disclosure Director&#8217;s Special at the end of the series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2008/11/23/environmental-friendly-css-the-series/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Label element secret powers</title>
		<link>http://www.maratz.com/blog/archives/2008/09/14/label-element-secret-powers/</link>
		<comments>http://www.maratz.com/blog/archives/2008/09/14/label-element-secret-powers/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 13:43:09 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=492</guid>
		<description><![CDATA[In web forms, label element plays an important role. It describes the corresponding form field, whether it&#8217;s a text field, radio button, checkbox or a drop-down. The label is an essential interface element for challenged people. If labels are properly set, user agents attach a behavior: when a label is clicked with a mouse — [...]]]></description>
			<content:encoded><![CDATA[<p>In web forms, <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1">label element</a> plays an important role. It describes the corresponding form field, whether it&#8217;s a text field, radio button, checkbox or a drop-down. The label is an essential interface element for challenged people.</p>
<p>If labels are properly set, user agents attach a behavior: when a label is clicked with a mouse — in most browsers — the related field gains focus. The behavior is quite useful, since it gives you possibilities to increase hit area for a field.</p>
<p>Gaining field focus works much like tabbing with a keyboard, but there are exceptions. When a form button (for example Submit) gains focus via keyboard navigation, naturally it is selected and ready to be stroked by Enter. But, if there&#8217;s a label assigned to it, hitting the label will also submit the form automatically.<span id="more-492"></span></p>
<p>There is many possibilities. One of them is hiding form button with CSS and style label more freely, since it is a plain inline element. Design/CSS-wise, think of it like a span but with an extra behavior built in.</p>
<pre>&#60;label for="send"
	style="background-image: url(send-button.gif);">
	&#60;input type="submit" id="send" value="Send"
		style="position: absolute; left: -9999px;" />
&#60;/label></pre>
<p>You can nest fields inside labels and increase hit area, which many people do by default with checkboxes and radio buttons.</p>
<pre>&#60;label for="sure">
	&#60;input type="checkbox" value="1" id="sure" name="sure" />
	Are you sure?
&#60;/label></pre>
<p>Another interesting application is adding multiple labels for the same field — for instance, one right next to checkbox, and another one in a supporting paragraph where you can contextually anchor keywords directly to that checkbox.</p>
<pre>&#60;p>If you are absolutely sure, then
	&#60;label for="sure">confirm it&#60;/label> in the form.&#60;/p>

&#60;label for="sure">
	&#60;input type="checkbox" value="1" id="sure" name="sure" />
	Are you sure?
&#60;/label></pre>
<p>Last, but not least, labels provide valuable connection between two elements, which gives you <a href="http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/">opportunity for a unique interface designs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2008/09/14/label-element-secret-powers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CSS 101: How to offset background from the right or bottom</title>
		<link>http://www.maratz.com/blog/archives/2008/08/23/how-to-offset-background-from-the-right-or-bottom/</link>
		<comments>http://www.maratz.com/blog/archives/2008/08/23/how-to-offset-background-from-the-right-or-bottom/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 20:23:30 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/?p=163</guid>
		<description><![CDATA[Advanced Cascading Style Sheets trick. Geeks only.]]></description>
			<content:encoded><![CDATA[<div class="alignleft-pull">
<p><em>CSS level: beginner/intermediate</em></p>
</div>
<div class="post-update">
<p>CSS3 now supports background-position property: <a href="http://www.w3.org/TR/css3-background/#background-position">http://www.w3.org/TR/css3-background/#background-position</a></p>
</div>
<p><code>Background-position</code> CSS property allows us to position background image starting from top left corner of a HTML element.</p>
<p>We are able to position either with some numeric values such as <code>100%</code> and<code>10px</code>, or with keywords such as <code>left</code> and <code>bottom</code>. Either way, you always have to offset it from the top left corner.</p>
<p>If the design dictates positioning background image to bottom right corner, obviously we would use <code>background-position: 100% 100%;</code></p>
<p>But sometimes we need an offset from the bottom right. And if you also have expanding box, it doesn&#8217;t come by default in CSS.<span id="more-163"></span></p>
<p>We are all aware that fixed height layouts are matter of history, but bare with me for a moment — with fixed width/height layouts background positioning is fairly easy. You always know where the background image will end, thus you can make it a little bit smaller in size than the element itself.</p>
<p>For example: if a paragraph is 300px wide, we can set the background-image in a way to leave a 10px wide empty area on the right.</p>
<p>First, let&#8217;s see the rule:</p>
<pre>p {
    width: 260px;
    height: 260px;
    padding: 20px;
    background: url(image.gif) no-repeat 0 0;
}</pre>
<div><img src="http://www.maratz.com/img/2008/08-aug/background-290.gif" alt="Cut background" width="420" />
<p class="caption">Figure 1. Background image is cropped to 290 x 290px</p>
</div>
<p>In this example, if we crop the background image to be 290 x 290px, you can easily achieve an effect of <a href="http://webdesign.maratz.com/lab/background-position/fixed.php">background image being 10px shorter and 10px thiner than the paragraph</a>.</p>
<p>I agree, it&#8217;s no brainer. But keep reading.</p>
<h2>Flexible is new fixed</h2>
<p>With liquid or flexible layouts, dimensions of HTML elements are variable (different screen resolutions, window resizing, etc.). Say we have:</p>
<pre>p {
    width: 100%;
    height: 100%;
    background: url(image.gif) no-repeat 100% 100%;
}</pre>
<p>I&#8217;ve seen developers reach for another element to achieve the offset. And really, if you&#8217;re in a hurry, add a child element, offset it with a margin, and then paste the background to that inner element.</p>
<p>Naturally, there is a better way.</p>
<p>Open the background image with Photoshop, and choose Image → Canvas Size (or Command/Ctrl + Alt/Option + C)  </p>
<div class="alignleft-pulllarge image"><img src="http://www.maratz.com/img/2008/08-aug/canvas-resize.jpg" alt="Select Image → Canvas Size" width="640" />
<p class="caption">Figure 2. Resizing canvas</p>
</div>
<p>Enter the values as shown on the Figure 2. (tip: if you check Relative, you can use mathematical operands). When you&#8217;re done, hit OK.</p>
<p>You should have some empty space on the right and bottom.</p>
<div class="image"><img src="http://www.maratz.com/img/2008/08-aug/empty-space.gif" alt="Empty space around image" width="420" />
<p class="caption">Figure 3. Empty space after Canvas Resize</p>
</div>
<p>Save image as a GIF with transparency on and voilá &#8211; it&#8217;s <a href="http://webdesign.maratz.com/lab/background-position/flexible.php">always shifted 10px from the bottom and 10px from the right</a> (resize your browser window or increase font size when you are checking the example).</p>
<p>At first, you might wonder where you should use this technique, but once you get your fingers on flexible layouts, you might find this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2008/08/23/how-to-offset-background-from-the-right-or-bottom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web typography: bottom margins of paragraphs and lists</title>
		<link>http://www.maratz.com/blog/archives/2007/05/12/quick-tip-bottom-margins-of-paragraphs-and-lists/</link>
		<comments>http://www.maratz.com/blog/archives/2007/05/12/quick-tip-bottom-margins-of-paragraphs-and-lists/#comments</comments>
		<pubDate>Sat, 12 May 2007 21:28:44 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2007/05/12/quick-tip-bottom-margins-of-paragraphs-and-lists/</guid>
		<description><![CDATA[Bottom margins with CSS]]></description>
			<content:encoded><![CDATA[<p>Creating the perfect vertical space on the screen is easy. With a few lines of CSS, you&#8217;ll have a great typography foundation for your web site. Let&#8217;s begin&#8230;</p>
<p>Global line height is usually set to <code>html</code> or <code>body</code> element. In this quick lesson, we&#8217;ll use a line height of 1.5.</p>
<pre>
* { margin: 0; padding: 0; }
html { font: 62.5%/1.5 "Lucida Grande", Verdana, sans-serif; }
</pre>
<p>You&#8217;ll also notice that we reset margins and paddings globally with the universal selector.</p>
<p>Since the paragraphs and lists (and their child elements, too) inherit the line height value, setting margin bottom equal to element&#8217;s line height ensures correct vertical rhythm.</p>
<pre>
ul, ol, dl, p { margin-bottom: 1.5em; font-size: 1.2em; }
</pre>
<p>Most often&#8212;for various reasons&#8212;you don&#8217;t want to set font size of a block-level element that by default must have block-level children, like for instance unordered list must have. You would instead specify font size for list items, definition terms and definition descriptions:</p>
<pre>
li, dt, dd, p { font-size: 1.2em; }
ul, ol, dl, p { margin-bottom: 1.5em; }
</pre>
<p>Now we only have to redefine bottom margin of lists to 1.8em. It is calculated by simply multiplying element&#8217;s line-height by child element&#8217;s font size (<code>1.5 &times; 1.2em = 1.8em</code>)</p>
<pre>
li, dt, dd, p { font-size: 1.2em; }
ul, ol, dl { margin-bottom: 1.8em; }
p { margin-bottom: 1.5em; }
</pre>
<p>Use the same principle when dealing with other elements: headings, tables etc., and within a minutes a sound vertical spacing will be accomplished. Still hungry? Head on to <a href="http://24ways.org/2006/compose-to-a-vertical-rhythm">Compose to a Vertical Rhythm</a>.</p>
<h3>Addenum</h3>
<p>This article is also <a href="http://webgrower.ru/articles/layout-and-scripting/web-typography-bottom-margins.html">available in Russian</a>. Big thanks goes to <a href="http://webgrower.ru/">Errant</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2007/05/12/quick-tip-bottom-margins-of-paragraphs-and-lists/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>IE 7 quirks: floats and margins, here we go again</title>
		<link>http://www.maratz.com/blog/archives/2006/11/11/ie-7-quirks-floats-and-margins/</link>
		<comments>http://www.maratz.com/blog/archives/2006/11/11/ie-7-quirks-floats-and-margins/#comments</comments>
		<pubDate>Sat, 11 Nov 2006 18:33:40 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2006/11/11/ie-7-quirks-floats-and-margins/</guid>
		<description><![CDATA[More IE oddities]]></description>
			<content:encoded><![CDATA[<p><a href="http://webdesign.maratz.com/lab/ie7_ignored_float_bottom_margin/" title="See demo page"><img class="alignleft" src="/img/sshots/ie7_bottom_margin_float.gif" alt="Bug Screenshot" title="" width="210" height="160" /></a> We&#8217;ve been introduced with <a href="http://www.microsoft.com/windows/ie/" title="Download latest Internet Explorer version">the latest Internet Explorer</a> few weeks ago and some quirks <a href="/blog/archives/2006/10/23/ie-7-quirks-round-one/">have been explained already</a>. In this article, we&#8217;re dealing with a single (but pretty nasty) bug &#8211; neglected bottom margin set at the floating child element.<span id="more-197"></span></p>
<p>The following markup:</p>
<pre>&#60;div class="wrapper">
    &#60;div class="inner">
    ... some content goes here...
    &#60;/div>
&#60;/div></pre>
<p>and the corresponding CSS rules:</p>
<pre>.wrapper { float: left; }
.inner { float: left; margin-bottom: 30px; }</pre>
<p>should make <code>.wrapper</code> 30 pixels higher than <code>.inner</code>, right?</p>
<p>In IE 7 this is not a case. Instead, to achieve the same effect, one should set bottom padding at the <em>parent</em> element:</p>
<pre>.wrapper { float: left; padding-bottom: 30px; }
.inner { float: left; }</pre>
</p>
<p>Yes, they fixed <a href="http://www.positioniseverything.net/explorer/doubled-margin.html">float doubled margin bug</a>, but brought us another one of the same sort. See <a href="http://webdesign.maratz.com/lab/ie7_ignored_float_bottom_margin/">demo page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2006/11/11/ie-7-quirks-floats-and-margins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fancy checkboxes and radio buttons with CSS</title>
		<link>http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/</link>
		<comments>http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/#comments</comments>
		<pubDate>Sun, 11 Jun 2006 20:37:13 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/</guid>
		<description><![CDATA[Get rid of the standard OS form controls]]></description>
			<content:encoded><![CDATA[<p>Many young guns ask about how to style custom checkboxes and radio buttons in forms. I prepared a typical markup, a few lines of CSS and some JavaScript functions (Safari <code>label</code> behavior fix included).</p>
<div class="alignleft-pulllarge"><a href="http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html"><img src="http://www.maratz.com/blog/wp-content/uploads/2006/06/fancycheckbox.jpg" alt="" title="See the demo" width="660" height="330" class="alignleft size-full" /></a></div>
<p>For those in a hurry, go straight to <a href="http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html">Fancy checkboxes demo page</a>. Also simple <a href="http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/jquery.html">jQuery version</a> available.</p>
<h2>The structure</h2>
<p>Each radio button and/or checkbox <code>input</code> element should be surrounded with <code>&#60;label></code> tags. Here&#8217;s the example:</p>
<pre>&#60;label class="label_check" for="sample-check">
    &#60;input name="sample-check" id="sample-check" value="1" type="checkbox" />
    Sample Label
&#60;/label>

&#60;label class="label_radio" for="sample-radio">
    &#60;input name="sample-radio" id="sample-radio" value="1" type="radio" />
    Sample Label
&#60;/label></pre>
<h2>The presentation</h2>
<p>We are going to remove inputs far away to the left and instead place a background image to each <code>label</code>. Radios and checkboxes will be toggled, because clicking/spacepressing the corresponding <code>label</code> toggles them on or off.</p>
<p>See the CSS sample:</p>
<pre>.has-js .label_check,
.has-js .label_radio { padding-left: 34px; }
.has-js .label_radio { background: url(radio-off.png) no-repeat; }
.has-js .label_check { background: url(check-off.png) no-repeat; }
.has-js label.c_on { background: url(check-on.png) no-repeat; }
.has-js label.r_on { background: url(radio-on.png) no-repeat; }
.has-js .label_check input,
.has-js .label_radio input { position: absolute; left: -9999px; }</pre>
<h2>The behavior</h2>
<p>And finally, some JavaScript trickery to handle all the <code>className</code> switching. In Safari, labels are not clickable, hence a few extra Safari speciffic lines.</p>
<pre>var d = document;
var safari = (navigator.userAgent.toLowerCase().indexOf('safari') != -1) ? true : false;
var gebtn = function(parEl,child) { return parEl.getElementsByTagName(child); };
onload = function() {

    var body = gebtn(d,'body')[0];
    body.className = body.className &#038;&#038; body.className != '' ? body.className + ' has-js' : 'has-js';

    if (!d.getElementById || !d.createTextNode) return;
    var ls = gebtn(d,'label');
    for (var i = 0; i &#60; ls.length; i++) {
        var l = ls[i];
        if (l.className.indexOf('label_') == -1) continue;
        var inp = gebtn(l,'input')[0];
        if (l.className == 'label_check') {
            l.className = (safari &#038;&#038; inp.checked == true || inp.checked) ? 'label_check c_on' : 'label_check c_off';
            l.onclick = check_it;
        };
        if (l.className == 'label_radio') {
            l.className = (safari &#038;&#038; inp.checked == true || inp.checked) ? 'label_radio r_on' : 'label_radio r_off';
            l.onclick = turn_radio;
        };
    };
};
var check_it = function() {
    var inp = gebtn(this,'input')[0];
    if (this.className == 'label_check c_off' || (!safari &#038;&#038; inp.checked)) {
        this.className = 'label_check c_on';
        if (safari) inp.click();
    } else {
        this.className = 'label_check c_off';
        if (safari) inp.click();
    };
};
var turn_radio = function() {
    var inp = gebtn(this,'input')[0];
    if (this.className == 'label_radio r_off' || inp.checked) {
        var ls = gebtn(this.parentNode,'label');
        for (var i = 0; i &#60; ls.length; i++) {
            var l = ls[i];
            if (l.className.indexOf('label_radio') == -1)  continue;
            l.className = 'label_radio r_off';
        };
        this.className = 'label_radio r_on';
        if (safari) inp.click();
    } else {
        this.className = 'label_radio r_off';
        if (safari) inp.click();
    };
};</pre>
<p>Also, be sure to check the previous post about <a href="/blog/archives/2006/06/07/preload-images-with-javascript/">how to preload all those interface graphics</a>.</p>
<h2>Demo</h2>
<p><a href="http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html">Fancy checkboxes demo page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2006/06/11/fancy-checkboxes-and-radio-buttons/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Preload :hover images in CSS</title>
		<link>http://www.maratz.com/blog/archives/2005/06/22/preload-hover-images-in-css/</link>
		<comments>http://www.maratz.com/blog/archives/2005/06/22/preload-hover-images-in-css/#comments</comments>
		<pubDate>Wed, 22 Jun 2005 10:42:21 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2005/06/22/preload-hover-images-in-css/</guid>
		<description><![CDATA[Now that the majority of CSS blogosphere is accessing the Internet with some kind of broadband connection, we kind of forget about Dial-up users. We do all kind of trickery to make our images lighter and faster to download, but even though, sometimes the first time visitor gets the flicker when hovering a link with [...]]]></description>
			<content:encoded><![CDATA[<p>Now that  the majority of CSS blogosphere is accessing the Internet with some kind of broadband connection, we kind of forget about Dial-up users. We do all kind of trickery to make our images lighter and faster to download, but even though, sometimes the first time visitor gets the flicker when hovering a link with a background image.</p>
<p>Most of the time, <a href="http://wellstyled.com/css-nopreload-rollovers.html">pixy&#8217;s workaround</a> with a single image, which is positioned accordingly will do, but sometimes for whatever reason, we need completely separate images. Preloading background images with CSS is so cheap trick, that I sometimes laugh at myself how could I forget about it.</p>
<pre>a { background: url(image_hover.gif); }
a:link { background: url(image_default.gif); }
a:hover,
a:focus { background: url(image_hover.gif); }
</pre>
<h3>Update</h3>
<p>The code example was rather generic, now it&#8217;s altered for those who are in a hurry :&nbsp;) and have no time to read through valuable discussion in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2005/06/22/preload-hover-images-in-css/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Essentials of CSS Hacking For Internet Explorer</title>
		<link>http://www.maratz.com/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/</link>
		<comments>http://www.maratz.com/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/#comments</comments>
		<pubDate>Thu, 16 Jun 2005 11:54:28 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/</guid>
		<description><![CDATA[How to apply CSS hacks safely]]></description>
			<content:encoded><![CDATA[<p>The summary of <a href="http://web.burza.hr/en/">our</a> <a href="http://www.nacional.hr/">latest project</a> client-side development brought to conclusion that there&#8217;re  are really just a few essential Internet Explorer hacks. By careful structure planning, I managed to stripe down all hackery to a much less additional rules. Since <a href="http://www.microsoft.com/">they</a> are promising IE7 some time soon, more and more I think about secure CSS hacking. We surely don&#8217;t want our sites to be a mess in IE7 for it&#8217;s quite possibly half-repaired <a href="http://blogs.msdn.com/ie/archive/2005/04/22/410963.aspx">CSS support</a>.<span id="more-104"></span></p>
<h3>Conditional Comments</h3>
<p>The alpha and the omega of IE hacking are IE&#8217;s <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">conditional comments</a>. They are IE-only feature and they&#8217;re not supported by any other browser. For other browsers they are just an ordinary comments and therefor, they are safe to use.</p>
<p>The typical usage is as follows:</p>
<pre>&#60;!--[if IE]&#62;
    do something
&#60;![endif]--&#62;</pre>
<p>Untill now I used to write something like above, which applies to all versions of Internet Explorer, i.e. 5.01, 5.5 and 6.0, but since the latest announcements, I started applying the following condition:</p>
<pre>&#60;!--[if lte IE 6]&#62;
    do something
&#60;![endif]--&#62;</pre>
<p>which means: &#8220;if this is Internet Explorer <strong>less than or equal to version 6</strong>, do something&#8221;. My thoughts are&#8212;if they keep conditional comments feature in IE7, then the browser will ignore this, since it&#8217;s version designation number is 7. On the other hand, if they abandon that feature, the browser will assume that this is just another HTML comment.</p>
<p>When I work on a layout I usually place all hacks for some selector immediately after its&#8217; default rule. This way, changes can be done quickly and without searching for the corresponding hack in other places.</p>
<p>After I&#8217;m done with layout, I like to go through all of the CSS files once again and optimize everything from short-hand properties to assigning the same rule for multiple selectors. At that point all hacks are removed to separate file(s), so the main CSS is clean and tidy. This separate file is then called in the header section of a file within conditional comments.</p>
<pre>&#60;!--[if lte IE 6]&#62;
    &#60;link rel="stylesheet" type="text/css" href="ie_hacks.css" /&#62;
&#60;![endif]--&#62;</pre>
<p>While still in main CSS file, hacked selectors start with <code>* html</code>. This is known as the &#8216;star-HTML&#8217; hack. Standard compliant browsers ignore this selector, because there&#8217;s actually  no elements above <code>html</code> in a document tree. Luckily, IE doesn&#8217;t know that and we&#8217;re safe to use this flaw when applying IE specific hacks. Once we move hacks to a separate file and call it in a document with conditional comments, it&#8217;s safe to remove the <code>* html</code> part.</p>
<p>Further on in the text, assume that we are dealing with separate file with IE hacks only.</p>
<h3>Backslash hack for IE 5.x broken box model</h3>
<p>A combination of width and padding on the same element is very well known to produce broken layouts in IE 5.x. Box model hack is widely used and can be stripped down to a few lines.</p>
<pre>someselector {
    padding: 10px;
    width: 200px;
    w&#92;idth: 180px;
    height: 200px;
    heigh&#92;t: 180px;
}</pre>
<p>This will give as an element which is 200px wide, 200px high and with 10px paddings in both IE 5.x and IE 6.</p>
<h3>If floated and with margin, display: inline</h3>
<p>Everything that is floated and has any margin larger than zero, should have additional rule <code>display: inline;</code>. Simple as that.  More about the &#8216;Holly hacks&#8217; read at <a href="http://www.positioniseverything.net/">P.I.E.</a>.</p>
<h3>Overflow problems</h3>
<p>Italic font style in any IE version will enlarge parent element horizontally. It&#8217;s usually just a few pixels, but it could be nasty and ugly few pixels. Simple solution is in the following rule:</p>
<pre>someselector {
    overflow-x: hidden;
}</pre>
<p>I tend to apply that rule to every major column in a layout, especially in the period right after site launch. For the first week or two, when the large amounts of content are added and removed day and night by the site&#8217;s editors, it&#8217;s better to prevent content slips out of it&#8217;s boxes. A small digression&#8212;editors are sometimes inexperienced, but it&#8217;s not their job to know every HTML element and that&#8217;s why adequate support in their few first attempts is essential. There&#8217;s no worst for the guy who manage the content on his company&#8217;s brand new, ultra-modern and expensive web site, than the massive layout breakage when the site is still fresh and under the eyes of CEO. It&#8217;s our responsibility to keep his confidence intact.</p>
<h3>Font size in tables in IE 5.x</h3>
<p>Font rules set in <code>html</code> or <code>body</code> element are ignored in tables in case of IE 5.x. Again, simple addition will take care of it.</p>
<pre>body {
    font-size: 62.5%;
}
table {
    font-size: 1em;
}</pre>
<p>Later in a process, you can change rules according to a particular table&#8217;s needs.</p>
<h3>To conclude&#8230;</h3>
<p>CSS hacks are necessary evil, but with defensive approach, we can make sure they safely co-exist with default CSS rules, even in future browsers. What are your thoughts?</p>
<h3>Related Reading</h3>
<ul>
<li><a href="http://www.positioniseverything.net/explorer.html">Position Is Everything</a></li>
<li><a href="http://tantek.com/CSS/Examples/boxmodelhack.html">Tantek&#8217;s Box Model Hack</a></li>
<li><a href="http://www.andybudd.com/archives/2003/08/avoiding_tanteks_box_model_hack/">Avoiding Tantek&#8217;s &#8220;Box Model Hack&#8221;</a></li>
<li><a href="http://www.informit.com/articles/printerfriendly.asp?p=170511">Strategies for Long-Term CSS Hack Management</a></li>
<li><a href="http://www.stylegala.com/resources/css_hacks.htm">CSS hacks | Stylegala</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2005/06/16/essentials-of-css-hacking-for-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Input Field Drop Shadow</title>
		<link>http://www.maratz.com/blog/archives/2005/05/04/input-field-drop-shadow/</link>
		<comments>http://www.maratz.com/blog/archives/2005/05/04/input-field-drop-shadow/#comments</comments>
		<pubDate>Tue, 03 May 2005 22:04:53 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2005/05/04/input-field-drop-shadow/</guid>
		<description><![CDATA[Amazing how I still receive many e-mails regarding those drop shadows in the input and textarea elements in web forms. This is very simple, so let&#8217;s explain it. All you need is background image of the drop shadow and a few CSS lines. Let&#8217;s begin with: input, textarea { background: url(drop_shadow_image.gif) no-repeat 0 0; } [...]]]></description>
			<content:encoded><![CDATA[<p>Amazing how I still receive many e-mails regarding those drop shadows in the <code>input</code> and <code>textarea</code> elements in web forms. This is very simple, so let&#8217;s explain it. All you need is background image of the drop shadow and a few CSS lines. <span id="more-90"></span>Let&#8217;s begin with:</p>
<pre>input, textarea {
    background: url(drop_shadow_image.gif) no-repeat 0 0;
}</pre>
<p>You might want to add class name for <code>type="text"</code> fields, so they are differentiated from checkboxes, radios or submit buttons (they are all <code>input</code> elements):</p>
<pre>&#60;input type="text" class="input_text" id="..." name="..." /></pre>
<p>and change CSS:</p>
<pre>.input_text, textarea {
    background: url(drop_shadow_image.gif) no-repeat 0 0;
}</pre>
<p>IE/Win has a problem with proper positioning of a background image in <code>textarea</code> element when you scroll inside it or maybe all others miss-behave. Anyway, we add:</p>
<pre>.input_text, textarea {
    background: url(drop_shadow_image.gif) no-repeat 0 0;
}
/* not for IE/Mac &#92;*/
* html textarea {
    background-attachment: fixed;
}
/**/</pre>
<p>Wanted more? Nope, that&#8217;s all&#8230; : )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2005/05/04/input-field-drop-shadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF Links Labeling</title>
		<link>http://www.maratz.com/blog/archives/2005/01/13/pdf-links-labeling/</link>
		<comments>http://www.maratz.com/blog/archives/2005/01/13/pdf-links-labeling/#comments</comments>
		<pubDate>Thu, 13 Jan 2005 12:16:51 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2005/01/13/pdf-links-labeling/</guid>
		<description><![CDATA[<a href="http://www.yourtotalsite.com/about/bios/Garrett.aspx">Garret Dimon</a> wrote nice post about why <a href="http://www.yourtotalsite.com/archives/usability/please_label_pdf_links/Default.aspx">PDF links should be labeled</a>. While there&#8217;s no problem making these labels when starting from scratch or re-designing web site, it&#8217;s a pain in the a** to add <code>class="pdfLink"</code> to existing (large) sites. Here&#8217;s JavaScript to the rescue.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.yourtotalsite.com/about/bios/Garrett.aspx">Garret Dimon</a> wrote nice post about why <a href="http://www.yourtotalsite.com/archives/usability/please_label_pdf_links/Default.aspx">.PDF links should be labeled</a>. While there&#8217;s no problem making these labels when starting from scratch or re-designing web site, it&#8217;s a pain in the a** to add <code>class="pdfLink"</code> to existing (large) sites. Here&#8217;s JavaScript to the rescue.<span id="more-72"></span></p>
<p>If you have read my post about <a href="http://www.maratz.com/blog/archives/2004/11/29/setting-target_blank-to-external-links/">adding target=&#8221;_blank&#8221; to external links</a>, you are half way there. The script is basically the same, but the conditions are changed. Instead of applying <code>target</code> attribute to all external links, the script applies this attribute to all URLs that have a string &#8216;.pdf&#8217; in it or as you will see later, to any custom file extension (i know some of you will disagree with opening links in new window, but that&#8217;s not today&#8217;s topic).</p>
<p>The script also adds <code>class="pdfLink"</code> to all links that match the condition. Same could be applied to .DOC files or .ZIP files.</p>
<pre>function fileLinks() {
    var fileLink;
    if (document.getElementsByTagName('a')) {
        for (var i = 0; (fileLink = document.getElementsByTagName('a')[i]); i++) {
            if (fileLink.href.indexOf('.pdf') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pdfLink';
            }
            if (fileLink.href.indexOf('.doc') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'docLink';
            }
            if (fileLink.href.indexOf('.zip') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'zipLink';
            }
        }
    }
}
window.onload = function() {
    fileLinks();
}</pre>
<p><img src="http://webdesign.maratz.com/lab/pdf_links_labeling/all.gif" alt="preview of icons" /> Now that we have classes <code>pdfLink</code>, <code>docLink</code> and <code>zipLink</code>, we can use CSS to style those links, for example add a corresponding icons. See following example:</p>
<pre>.pdfLink { padding-right: 19px; background: url(pdf.gif) no-repeat 100% .5em; }
.docLink { padding-right: 19px; background: url(doc.gif) no-repeat 100% .5em; }
.zipLink { padding-right: 17px; background: url(zip.gif) no-repeat 100% .5em; }</pre>
<p>I suggest you use small and unobtrusive, but noticeable icons, otherwise they will take too much attention. Here is <a href="http://webdesign.maratz.com/lab/pdf_links_labeling/">full working example</a>. The script is not bullet-proof to URL junk produced by CMS, for example <code>?download=2387423&#38;sid=8568347563</code>. Links should point to files with the right extensions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2005/01/13/pdf-links-labeling/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>10 Minutes to Printer Friendly Page</title>
		<link>http://www.maratz.com/blog/archives/2004/09/21/10-minutes-to-printer-friendly-page/</link>
		<comments>http://www.maratz.com/blog/archives/2004/09/21/10-minutes-to-printer-friendly-page/#comments</comments>
		<pubDate>Tue, 21 Sep 2004 18:07:55 +0000</pubDate>
		<dc:creator>Marko Dugonjić</dc:creator>
				<category><![CDATA[coding/design]]></category>
		<category><![CDATA[CSS 101]]></category>
		<category><![CDATA[accessibility]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2004/09/21/10-minutes-to-printer-friendly-page/</guid>
		<description><![CDATA[An explanation and examples of PHP and ASP scripts which provides printer friendly version of some article, entry or post.]]></description>
			<content:encoded><![CDATA[<p>Providing separate stylesheets for printing a web page was <a href="http://www.alistapart.com/articles/goingtoprint/">good idea in theory</a>, but <a href="http://www.themaninblue.com/writing/perspective/2004/07/09/">in practice it all falls down</a>. Let&#8217;s see if we can do something about it. If we could involve server-side script (there&#8217;s solution for both&#8212;PHP and ASP based systems *wink, wink*) which will reload that particular page, but replace regular CSS file with stylesheet specially suitable for printing an article, entry, post or whatever-you-wanna-call-it, this would make a hudge step forward towards better usability of our web site. Oh, and yes, Google will just love it!<span id="more-57"></span><br />
<h3>One page, two stylesheets</h3>
<p>Okay, you probably have a page with some content and you probably have styled it with some CSS. If you already have print stylesheet for your page, just <a href="#printQuery">skip ahead to the next part</a>.</p>
<p>To make stylesheet for printing, decide what parts of your layout are not likely to be printed (like various banners, navigation etc.). The simplest way to hide them is to define them as <code>display: none;</code>. If you are not familiar with stylesheets for print <a href="http://www.alistapart.com/articles/printyourway/">read more about it</a>. Anyway, keep it simple&#8212;black text on the white background, with a <code>font-size: 12pt;</code> is a good start. When you&#8217;re done with it, continue reading.</p>
<h3 id="printQuery">The query</h3>
<p>Now that we have all client-side ingredients in place, we can put it all together. First, we have to add a link somewhere around the article, for example:</p>
<pre>&#60;h1&#62;Title of the article&#60;/h1&#62;
&#60;p&#62;Lorem ipsum...&#60;/p&#62;
<strong>&#60;a href="?q=printme"&#62;printer friendly version&#60;/a&#62;</strong></pre>
<p>It literally means we are requesting this same page, but with a query <code>q=printme</code>. To make our page recognizes what we are asking it, we have to add somewhere in the <code>&#60;head&#62;</code> section some logic, something like:</p>
<p><blockqute>
<p>&#8220;If i&#8217;m asked to &#8216;printme&#8217;&#8212;i&#8217;ll load my printing stylesheet, and if i&#8217;m not asked anything&#8212;i&#8217;ll load my default CSS file.&#8221;</p>
<p>Depending of your preferences there are two scripts&#8212;<a href="#phpPrintScript">PHP</a> and <a href="#aspPrintScript">ASP</a>. Backup your HTML file and replace the part where you called your CSS file with one of the following examples.</p>
<h4 id="phpPrintScript">PHP print script</h4>
<pre>&#60;?php if ($_GET['q'] == "printme") { ?&#62;
&#60;link rel="stylesheet" type="text/css" href="print.css" /&#62;
&#60;?php } else { ?&#62;
&#60;link rel="stylesheet" type="text/css" href="default.css" /&#62;
&#60;?php } ?&#62;</pre>
<h4 id="aspPrintScript">ASP print script</h4>
<pre>&#60;% If Request.QueryString("q") = "printme" Then %&#62;
&#60;link rel="stylesheet" type="text/css" href="print.css" /&#62;
&#60;% Else %&#62;
&#60;link rel="stylesheet" type="text/css" href="default.css" /&#62;
&#60;% End if %&#62;</pre>
<h3>Happy printing</h3>
<p>Your visitors will love this, as they can decide whether they want to print your page for its&#8217; graphics or just the plain text (see <a href="?styling=print">printer friendly version of this entry</a>). As a benefit, Google will index two versions of the same article which should also help boosting your page rank.</p>
<p>Suggestions and re-workings are welcome as usual. Have a fun and please contact me when you make yours. I&#8217;d really like to see how you solved it!</p>
<h3>Update</h3>
<p>Almost one year later, Roger Johansson pulls out the subject for reconsideration &#8211; <a href="http://www.456bereastreet.com/archive/200509/printfriendly_css_and_usability/">Print-friendly CSS and usability</a>.</p>
<p></blockqute></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maratz.com/blog/archives/2004/09/21/10-minutes-to-printer-friendly-page/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

