Archive

Archive for the ‘HTML’ Category

Creating scalable sites using em, rather than px

April 20th, 2009 ben No comments

The Problem:

Modern websites are no longer visited by pale pasty individuals with bulky desktop computers and pitifully slow 14.4kb modems. These days even the most basic mobile phones contain faster processors and (in a lot of cases) higher resolution screens than full-size computers from 18 years ago (think Amiga 500+).

Being able to access information from anywhere in the world and on different devices has two major obstacles:

  • Bandwidth
  • Presentation

If you create a site that has fixed sized elements (using px to specify sizes) and/or heavily laden with images, flash etc then their is a good chance it will load incorrectly or take considerably longer to load on slower connections. There are a number of things we can do to correct this, but in this article I will look specifically at font sizing.

In traditional typed printed media, fonts have been specified using pixels. With the first itteration of webstandards font-sizes were specified using the built in browser presets (think IE and smaller, small, large, larger) or specifying a font height in pixels, such as 12px. Using px to specify font-sizes is perfect if you can guarantee that every screen will have the same resolution and screen size (say 15″ at 1024×768). However as computer displays have evolved and become larger or they become mobile and therefore smaller, these dimensions have changed drastically; and measuring the font in pixels, simply will not work..

Example 1:

Text at 12px, on a 19″ 800×600, will appear half the size on the same screen if we increase the resolution to 1600×1200 (because we now have twice as many pixels)

Example 2:

12px text on a 19″ 800×600, is going to become miniscual (and most probably unreadable) on an iPhones 480×320 3.5″ screen.

The Solution:

Anyway… enough of the reasons why px shouldn’t be used…. what we need to know is what is a more viable solution, something that will work on a variety of equipment. The closest thing that exists at the moment is the em measurement. em represents a relative size. So, a font-size of 1em is the same size of its parent element, a font-size of 0.8em is 20% smaller than its parent element… and I can hear you thinking… “But where does the parents font-size come from!?”.

Generally speaking browsers set their default font-size to 16px, so if I gave a <p> block a font-size of 0.8em, the font would be rendered with a font size of approx 12.8px, the biggest disadvantage to this (besides em measurements not working in older browsers) is that if the user changes their browsers default font-size, our font-sizes will change accordingly.

This ‘relative’ font size allows us to correct for different rendering of fonts because if for example, I visit a site on my iPhone, its browsers default font-size should be something that is readable by someone using the device, and my stylesheet modifications, should increase or decrease that font-size proportionally.

Equally, with em sizes you have to be careful if you find yourself nesting different font sizes.

Example:

<div style=”font-size: 0.8em”>

<div style=”font-size: 0.8em”>

Some text

</div>

</div>

This will cause the font to be reduced twice. The default font size of 16px will be reduced to 12.8px and then again to 10.24px. Ughhh.

Useful Links:

The information in the article, while I wish it was original research came from several sources on the net, but most noticeably from the two below.

No72DPI

BigBaer CSS Font-Sizes

A simple but effective OS X Link Checker – Integrity

April 4th, 2009 ben No comments

While I am on the subject of useful OS X web development software I wanted to let you know about a cool “Xenu’s Link Sleuth” alternative (LS is a popular windows based link checker). On OS X their isn’t a lot of choice, however we only need one and “Integrity” provides all of the features we need.

I can tell ‘Integrity’ to not follow a paticular URL string, I can tell it to follow a paticular URL string etc. The results page can then be browsed for missing links (of course) and exported to a CSV file for further analysis…. Simple but effective!

Categories: HTML, Tools Tags: , ,

FavIcons and the Apache Error Log, damn you IE!

March 30th, 2009 ben No comments

Having written a small post about favicons, I stumbled across some interesting information while looking through works apache error log. Besides being HUGE, it was also annoyingly filled with favicon.ico missing statements.

This wouldn’t be such a big problem, if it wasn’t for the fact that I have never referenced a file called favicon.ico (for that matter my favicon are .PNGs). It turns out that IE5 by default looks for ‘favicon.ico’ in sites root directory, regardless of whether you specified a meta location or not (see the post below).

The solution?…. Nothing elegant I am afraid. Your chooses:

  1. Place the ‘favicon.ico’ in your sites root directory
  2. Inform apache that the file isn’t their and too not even bother looking (http://www.trilithium.com/johan/2005/02/no-favicon/)
  3. Create a dummy favicon.ico and place it in the root directory

I hate IE…

Categories: HTML, images Tags: , ,

FAV Icons… the finishing touch to any website.

March 12th, 2009 ben No comments

Often the forgotten final element to a website, the favicon is the ‘je suis je reste’ (to quote del boy). It allows a mini icon to be displayed on your bookmarks and in the corner of most popular browsers tabs..

To maximise compatibility it needs to be 16×16 pixels, and either a Jpeg, gif or png (I prefer the later).

<link rel='icon' type='image/png' href='./Images/favicon.png' />

Place the above code (with the correct path) in between your <head> tag for favicon goodness :)

Categories: HTML Tags: , , , ,