Fixit – Measures

Avoiding pixel and absolute measures allows the browser to adapt content to fit the display, though there are exceptions to this rule (see below). This test checks for the use of absolulte and pixel measures where relative measures would be more appropriate

Using relative measures

You should try to use relative measures where possible. You can achieve this using measures such as em, ex, bolder, larger and thick.

e.g. Specify font size:

Correct: font-size: 1.5em;

Incorrect: font-size: 12px;

 

Exceptions

It is not always desirable to use relative measures. For instance, images may be tailored to fit particular displays. In this case it makes more sense to specify the dimension in pixels.

Note:
The intrinsic size of images must be specified as attributes of the img element and not as CSS properties!

There are also other situations where pixel measures might be more appropriate: margins, borders and padding are all examples of when you might want to use pixel measures instead.

 

Passing the test

This test checks your CSS properties as follows:

Any property which is not a padding, border or margin property, and which is not specified as a percentage, or using units em or ex will cause the test to fail.

You should therefore only use pixel measures where the property is not one of those mentioned above.

 

Reference

This test is based on a W3C mobileOK best practice. See http://www.w3.org/TR/mobile-bp/#MEASURES for more details.

Leave a Reply

Exclusive tips, how-tos, news and comment

Receive monthly updates on the world of mobile dev.

Other Afilias Products

Try the world’s leading device detection solution at
DeviceAtlas - Try the world’s leading mobile device detection solution

Evaluate your websites’ mobile readiness with
mobiReady - Evaluate your websites’ mobile readiness.

© 2019 Afilias Technologies Ltd. All rights reserved.

This is a website of Afilias Technologies Ltd, a private company limited by shares, incorporated and registered in the Republic of Ireland with registered number 398040 and registered office at 6th Floor, 2 Grand Canal Square, Dublin 2, Ireland