16

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

LiuYan 刘研
  • 1,614
  • 1
  • 16
  • 29
  • A font size should be defined in points IMHO. It's been going on that way for nearly 600 years, no reason to stop now. – user207421 Dec 11 '13 at 07:18
  • 1
    @EJP well, at that time, pixel wasn't born yet. and sometimes (such as display pictures by using color text in HTML) pixel is the best choice to define font size. – LiuYan 刘研 Dec 12 '13 at 02:29

1 Answers1

20

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.

Zeta
  • 103,620
  • 13
  • 194
  • 236
  • 1
    yes, the CSS recommendation allows real numbers. but if the media is screen, then what's the difference between `13.1px` and `13px`, i mean, you can't divide one pixel into ten 0.1 pixels, pixel is the smallest unit in screen. and i didn't see other CSS selectors (which may use relative length values and may make fraction becomes integer) inherit from that selector in that page. – LiuYan 刘研 Dec 12 '13 at 02:19
  • 17
    There is a distinction between device pixels and display pixels. For instance, if you're on a retina device and the user has zoomed the document, tenths of a pixel will make a noticeable difference. In this case the display pixels do not map 1:1 to device pixels. – fgshepard Jun 27 '14 at 14:53