<?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>David Oliver &#187; css</title>
	<atom:link href="http://blog.doliver.co.uk/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.doliver.co.uk</link>
	<description>web design and life</description>
	<lastBuildDate>Sat, 14 Aug 2010 20:23:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Get up and running with @font-face</title>
		<link>http://blog.doliver.co.uk/2010/03/get-up-and-running-with-font-face/</link>
		<comments>http://blog.doliver.co.uk/2010/03/get-up-and-running-with-font-face/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 08:37:15 +0000</pubDate>
		<dc:creator>David Oliver</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[fonts]]></category>

		<guid isPermaLink="false">http://blog.doliver.co.uk/?p=225</guid>
		<description><![CDATA[Here&#8217;s a very quick introduction to using the CSS fonts module intended for web designers who have a good knowledge of CSS but haven&#8217;t as yet experimented with @font-face rules. Internet Explorer 6 onwards and recent versions of all mainstream browsers support the CSS fonts module. Preparing the font files and CSS The quickest and [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a very quick introduction to using the CSS fonts module intended for web designers who have a good knowledge of CSS but haven&#8217;t as yet experimented with @font-face rules.</p>
<p>Internet Explorer 6 onwards and recent versions of all mainstream browsers support the CSS fonts module.<span id="more-225"></span></p>
<h2>Preparing the font files and CSS</h2>
<p>The quickest and most efficient way of preparing font files and getting appropriate CSS to use them that I&#8217;m aware of is the <a href="http://www.fontsquirrel.com/fontface/generator">Font Squirrel @font-face Generator</a>. Here are a few notes on using it and choosing from its options.</p>
<div id="attachment_235" class="wp-caption alignnone" style="width: 141px"><a href="http://blog.doliver.co.uk/wp-content/uploads/2010/03/fontsquirrel-fontfacegenerator.png"><img class="size-medium wp-image-235" title="Font Squirrel font-face Generator" src="http://blog.doliver.co.uk/wp-content/uploads/2010/03/fontsquirrel-fontfacegenerator-131x300.png" alt="Font Squirrel font-face Generator screenshot" width="131" height="300" /></a><p class="wp-caption-text">My currently preferred settings</p></div>
<h3>Adding fonts</h3>
<p>Clicking the Add Fonts button allows you to select the font(s) you wish to use. If you don&#8217;t already have a font that is legal to use via @font-face, have a read of <a href="http://nicewebtype.com/notes/2009/10/20/where-to-get-web-fonts/">Where  to get web fonts</a>.</p>
<h3>Font formats</h3>
<p>Different browsers have different font format-reading capabilities, so more than one format of font is required. Each browser will only have to download one format, so don&#8217;t worry about extra bandwidth being wasted.</p>
<p>Very briefly: TrueType is used by many, EOT is the only format Internet Explorer can use, and WOFF can be used by Firefox. I use <strong>TrueType</strong>, <strong>EOT</strong> and <strong>WOFF (OpenType)</strong>.</p>
<h3>Alternate Formats</h3>
<p>@font-face rules are well supported, so <strong>Cufón</strong> shouldn&#8217;t be necessary.</p>
<h3>Font Options</h3>
<p>I&#8217;ve found <strong>Add Hinting</strong> to improve font rendering in Windows, so I keep this option selected.</p>
<p>File sizes of fonts have been quite small, so I don&#8217;t feel the need to <strong>Simplify Outlines</strong>. And the same goes for <strong>Remove Kerning</strong>.</p>
<p>However, reducing file sizes without loss of quality is always a good thing to do, and subsetting fonts can really make a difference, especially if the font you are using has an extensive range of glyphs. So tick <strong>Subset Font&#8230;</strong> and spend a little time narrowing down the included glyphs to those you will actually use this font for with the aid of the font-face generator&#8217;s easy-to-use options.</p>
<p>I haven&#8217;t experimented with the <strong>Base64 Encode</strong> option as yet, but not all browsers can use it anyway.</p>
<h3>CSS Code</h3>
<p>I opt for the <strong>&#8220;Mo&#8217; Bulletproofer&#8221;</strong> method from Richard Fink as it avoids Internet Explorer making requests of your server which result in 404&#8242;s. You can read technical details about the methods using the links under the fields at Font Squirrel&#8217;s page if you wish to know about the ins and outs.</p>
<h3>Agreement</h3>
<p>As you&#8217;re putting the resultant files in a publicly accessible place, download-able by all, it&#8217;s important that you use fonts that come with the appropriate permissions.</p>
<h3>Download Your Kit</h3>
<p>Once you&#8217;ve signaled your agreement, the download button will appear.</p>
<h2>Testing</h2>
<p>Extract the zip file you&#8217;ve downloaded and open up demo.html in a web browser to see the font at various sizes. Check that it displays in an acceptable fashion at the kind of size you&#8217;ll be using it in different browsers. Particularly look out for the display quality in Windows versions of browsers.</p>
<h2>Using</h2>
<p>Copy the actual font files (e.g. .eot, .ttf, .woff) to your website directory. I place them in a subdirectory called &#8216;fonts&#8217;.</p>
<p>Open up stylesheet.css in your text editor and copy the given CSS into an appropriate CSS file of your own that is used by your pages.</p>
<p>Example CSS:</p>
<pre>@font-face {
    font-family: 'BallparkWeiner';
    src: url('ballpark_weiner.eot');
}

@font-face {
    font-family: 'BallparkWeiner';
    src: url(//:) format('no404'), url('ballpark_weiner.woff') format('woff'), url('ballpark_weiner.ttf') format('truetype');
}</pre>
<p><strong>font-family</strong> can be anything you like.</p>
<p>Unless you keep your CSS file and font files in the same directory, you will need to change the src urls in the CSS. For example, if you keep your font files in /fonts and your CSS files in /css, you would change</p>
<pre>url('font_name.ttf')</pre>
<p>to</p>
<pre>url('../fonts/font_name.ttf')</pre>
<p>Then style elements which should be displayed in the new font with CSS. An example:</p>
<pre>h1 {
    font-family: 'BallparkWeiner', Georgia, serif;
}</pre>
<p>Test in a variety of browsers, and enjoy your new-found typographic freedom!</p>
<h2>Further reading</h2>
<p><a href="http://nicewebtype.com/">Nice Web Type</a> has some excellent articles on technical details, font licensing information and where to get fonts which can be used with @font-face rules.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.doliver.co.uk/2010/03/get-up-and-running-with-font-face/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hacking &#8216;paragraph spacing&#8217; with CSS (despite IE)</title>
		<link>http://blog.doliver.co.uk/2010/01/hacking-paragraph-spacing-with-css-despite-ie/</link>
		<comments>http://blog.doliver.co.uk/2010/01/hacking-paragraph-spacing-with-css-despite-ie/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 20:31:24 +0000</pubDate>
		<dc:creator>David Oliver</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://blog.doliver.co.uk/?p=95</guid>
		<description><![CDATA[I feel that now is a good time to finally start using more of the CSS2 and CSS3 goodness in my web page styling [...], so I'll be testing these projects further with a view to settling on a solution.]]></description>
			<content:encoded><![CDATA[<p>Even though &#8216;paragraph spacing&#8217; (here referring to setting the space above and/or below a paragraph or other text element) is a simple enough concept in itself, when dealing with it in the context of web pages it can be worth reassessing our methodology. Are you using CSS as efficiently as you could be?<span id="more-95"></span></p>
<h2>Print design and text frames</h2>
<p>When thinking about ways to apply paragraph spacing to text in documents, I&#8217;m often reminded of my time working at a printer&#8217;s studio. When using QuarkXPress, and later InDesign, we could use &#8216;paragraph styles&#8217; to assign spacing above or below text, and different people in the studio had their own ways of working things. If I remember correctly, I usually inserted space <em>before</em> my paragraphs, and my colleague who sat at the desk next to me inserted space <em>after</em> his paragraphs. It was interesting to discuss the pros and cons of each approach, and I enjoyed picking up tips which I could then use in future.</p>
<div id="attachment_140" class="wp-caption alignleft" style="width: 223px"><img class="size-full wp-image-140" title="InDesign paragraph palette" src="http://blog.doliver.co.uk/wp-content/uploads/2010/01/indesign-paragraph.png" alt="InDesign paragraph palette" width="213" height="174" /><p class="wp-caption-text">14pt &#39;space before&#39; applied to a paragraph in InDesign</p></div>
<p>Now, when a heading or paragraph which is set to have space before it (e.g. 14pt) sits at the top of a text frame in a QuarkXPress or InDesign document (e.g. a non-breaking subheading that happens to start a new page), it does not have its before paragraph spacing applied, and continues to butt up against the top of its containing text frame.</p>
<p>In the context of print artwork, this approach by desktop publishing software works well and avoids many awkward situations. However, a web page requires more strict application of style rules. There is no such concept as a text frame in web pages &#8211; they are themselves textual documents.</p>
<h2>The issue in web pages</h2>
<p>For us web designers, a heading or paragraph keeps its top margin even if it is the first element in its parent element, which means we sometimes have to explicitly assign styling to get rid of unwanted margin-top values.</p>
<h3>An old way</h3>
<p>One suboptimal method was to assign a class to the first text element (in the example below, a heading) to which we wished to give a zero top margin.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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;articles&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;first&quot;</span>&gt;</span>Heading<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></div>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></div></div>
<p>A disadvantage to this method is that we were introducing a presentational-only class, meaning it was inefficient and did not really align with the concept of keeping our markup structural. If a new element was inserted before the heading (e.g. an image), we would have had to manually remove the class from our paragraph and apply it to our new element instead.</p>
<h3>A &#8220;new&#8221; way</h3>
<p>My brother, <a title="Ian Oliver" href="http://ioliver.co.uk/">Ian</a>, came up with a far better way yesterday.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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;articles&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Heading<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></div>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #cc00cc;">#articles</span> <span style="color: #00AA00;">&gt;</span> <span style="color: #3333ff;">:first-child </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></div></div>
<p>The CSS rule applies our desired zero top margin to any element which is the first child of our article div. It avoids having to assign a class to our element, leaving it free of unsemantic fluff, and thus requires no manual class switching should our content change. We can now set top and bottom margins to elements as we wish, and leave it to our new CSS rule to ensure we don&#8217;t have an unsightly gap at the top of the relevant content area. It&#8217;s adaptable, elegant, and is a good example of how simple styling a document with CSS can, and should, be.</p>
<p>Of course, this isn&#8217;t really a new method, and has been available to us for a long time courtesy of CSS2. The reason it may not have been at the forefront of our minds and present in our work until now is its lack of support in Internet Explorer 6.</p>
<h2>Pushing on despite IE6</h2>
<p>The above scenario is just one example of where using current capabilities of CSS can save us work and make life as authors of web pages decidedly easier, so it could be well worth investing a little time to get Internet Explorer 6 and 7 (and 8 when wanting to use CSS3) to play along with the rest of the world. Here are some options.</p>
<h3>ie7-js</h3>
<p><a title="A JavaScript library to make MSIE behave like a standards-compliant browser" href="http://code.google.com/p/ie7-js/">ie7-js</a> is &#8220;a JavaScript library to make MSIE behave like a standards-compliant browser&#8221;, and you can see the CSS support it adds at the projects <a title="ie7-js test page" href="http://ie7-js.googlecode.com/svn/test/index.html">test page</a>, as well as the rendering bugs it fixes.</p>
<p>Within the &#8220;ie7-js&#8221; project there are two main JavaScript scripts: IE7.js and IE8.js. If you decide to use IE8.js, you don&#8217;t need IE7.js as all its functionality is included in IE8.js. If you&#8217;re new to ie7-js, all the instructions you need are on the <a title="ie7-js project page" href="http://code.google.com/p/ie7-js/">main project page</a>.</p>
<h3>ie-css3.js</h3>
<p><a href="http://www.keithclark.co.uk/labs/ie-css3/">ie-css3.js</a> &#8220;allows Internet Explorer to identify CSS3 pseudo selectors and render any style rules defined with them&#8221;.</p>
<p>While IE8.js provides support for Internet Explorer for some CSS3 pseudo selectors (the ones which Internet Explorer 8 itself has as I understand it), there are others that it does not handle and which ie-css3.js does: :nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type and :only-of-type.</p>
<h3>eCSStender</h3>
<p>There is some overlap between IE8.js and ie-css3.js (and feature gap if IE7.js and ie-css3.js are used), meaning there&#8217;s still work to do on creating the &#8220;complete&#8221; solution. <a href="http://ecsstender.org/">eCSStender</a> (pronounced &#8220;extender&#8221;) sounds very powerful, but I haven&#8217;t looked at it in detail yet &#8211; it seems to be more complicated to use than the two aforementioned projects. Hopefully I can work it out to see if it can provide the CSS emulation for Internet Explorer that I&#8217;m after.</p>
<h2>No time like the present</h2>
<p>I feel that now is a good time to finally start using more of the CSS2 and CSS3 goodness in my web page styling that Internet Explorer and its market share have hitherto skuppered, so I&#8217;ll be testing these projects further with a view to settling on a solution.</p>
<p>Have you had experience with using new types of CSS selectors, and emulating CSS2 and CSS3 capabilities in Internet Explorer? I&#8217;d be very interested to hear how you&#8217;ve got on.</p>
<p><ins datetime="2010-02-02T10:23:40+00:00">Update: Chris Coyier has included <a href="http://css-tricks.com/snippets/css/remove-margins-first-element/">the basics of this approach in a more concise form at CSS-Tricks</a> &#8211; worth reading if the above isn&#8217;t clear to you.</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.doliver.co.uk/2010/01/hacking-paragraph-spacing-with-css-despite-ie/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
