Archive for the ‘Front end development’ Category

IE6 taking fire

Thursday, September 3rd, 2009

Internet Explorer’s version 6 has always been a hot discussion topic among webdevelopers. This not-quite-so-standard-compliant browser that once ruled the internet has made it into 2009 with user percentages dangling around 15% (and dropping). IE’s current version 8 is getting up-to-speed with quite-better-standard-compliant browsers like FireFox, Safari and Opera. With IE6 out of the picture we can move towards a browser-hack-free web, go crazy with those transparent PNG’s (IE6 is the last browser that doesn’t support it) and look forward to CSS3!

Anti-IE6 sites are suddenly all around and even Microsoft is pushing ie6 users to upgrade

internet-explorer-logo-with-pins

See more at:
http://www.ie6nomore.com/
http://www.bringdownie6.com/
http://ripie6.com/
http://www.saveie6.com/

http://uitrends.com/2009/08/25/an-open-letter-from-your-old-friend-ie6/
http://www.dearie6.com/

http://www.chigarden.com/2007/10/tutorial-making-the-ie-voodoo-doll/ shows a tutorial on how to make your own IE voodoo doll ;-)

css relative font size

Monday, August 10th, 2009

“Content is king” for most websites, so choosing the right font and font-size can have great impact on your website’s usability and accessibility. There are a few approaches when setting a font size for your website:

  • Don’t define font-sizes in your style sheet and let your browser take control
    good choice if you’re short on time and don’t mind cross-browser differences
  • Define absolute font sizes in your style sheet using keywords (xx-small, x-small, small, medium, large, x-large, xx-large)
    interpreted different throughout browsers
  • Define absolute font sizes using pixels
    Cross-browser support for pixels is good; downside is that Internet Explorers’ build-in text-sizing option refuses to resize text that is set in pixel values. Other browsers might force text-sizing, overruling the pixel values
  • Define absolute values using points
    Points are not meant to be used for screens, so just don’t
  • Define relative values using ems and percentages
    advised by the Web Accessibility Initiative (WAI).

A great number of website owners choose to set their font sizes at absolute pixel values, taking full control over their site’s appearance. But why not let your website users choose a font-size of their preference? They are the ones reading your content after all! Relative font sizing provides this option. Here are some facts to keep in mind when using relative values:

  • The default font-size for virtually all web browsers is the equivalent of 16 pixels
  • Both ems (e.g. 2em) and percentages (e.g. 200%) are relative units, always computed with respect to their parent element (this is called “inheritance”)
  • ems and percentages give similar results when applied to font-sizing, but behave different when used for sizing html elements.

Consider the following un-styled html code:

{code type=codetype}

<body>

<p></p>

</body>

{/code}

The font-size of the paragraph text will be that of the (first styled) parent element. Since there are no sized applied yet, the paragraph text will inherit the font-size of the <body> element that is equal to the browsers’ default 16px

Setting the paragraph to a value of 1em will result in an equivalent of 16px, 2em in an equivalent of 32px etc. but what if you would like to set the paragraph text to an equivalent of 18px? You would need to set a value of 18/16 = 1.13em.

To avoid these kind of calculations, I would advice to apply the 62,5% method in your style sheet.

{code type=codetype}body {font-size:62.5%}{/code}

This will reset the initial font size from 16px to 10px, making conversion a whole lot easier (1em=10px, 1.8em=18px etc.). Remember that the 10px value is only applied to the direct descendants of the <body> tag. When calculating font-sizes for nested elements, it can be useful to use this handy em calculator.

To control your font-size, i wrote this jQuery plugin, check it out.