Does floating point length value make sense on pixel unit?

10,127

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.

Share:
10,127

Related videos on Youtube

LiuYan 刘研
Author by

LiuYan 刘研

// unsigned char *p; // Map<String,Object> map; -- SELECT Name FROM ab -- INNER JOIN cdr ON ab.PhoneNumber=cdr.PhoneNumber /* pre {font-family: 'Ubuntu Mono';} */ <!-- <pre>© right?</pre> --> // function f() {} # echo -e "your message:\n$(fortune)" | \ # gpg -e --clearsign -o - -r [email protected] REM if ""%1"" == """" goto default ; exten => 911,1,Answer() svn commit -m "to be continue"

Updated on September 16, 2022

Comments

  • LiuYan 刘研
    LiuYan 刘研 almost 2 years

    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 刘研
      LiuYan 刘研 over 10 years
      @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 刘研
    LiuYan 刘研 over 10 years
    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.
  • fgshepard
    fgshepard almost 10 years
    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.