Does floating point length value make sense on pixel unit?

LiuYan 刘研 picture LiuYan 刘研 · Dec 11, 2013 · Viewed 8.8k times · Source

When I try write stylish CSS for forums.asterisk.org site, I saw they use floating point length value on pixel unit, for example: font-size: 13.1px;.

As far as I known, pixel is the smallest unit in screen, so does floating point length value make sense on pixel unit?

Screenshot

forums.asterisk.org site use floating point length value on pixel unit

Answer

Zeta picture Zeta · Dec 11, 2013

It's fine, the CSS recommendation allows numbers (not only integers) as values for pixels. Note that px is actually defined in terms of in in the recommendation:

‘px’: pixels; 1px is equal to 1/96th of 1in

All in all 13.1px will be the same as 0.1364in, where 13px would be 0.1354in. The difference is small, but noticeable.

That being said, you should use relative values in my opinion instead, and pt for the overall base size.