Can a CSS pixel be a fraction?

CssW3c

Css Problem Overview


Can a CSS px be a fraction? Is it allowed by the standards? And if so, do the major browsers support it?

Let's back the answers up with documentation, folks.

Css Solutions


Solution 1 - Css

Yes, you can specify fractional pixels. As this has been part of CSS since the very first version, it should be well supported by any browser that supports CSS at all.

Reference: CSS 2.1: 4.3.2 Lengths

> "The format of a length value (denoted by <length> in this > specification) is a <number> (with or without a decimal point) > immediately followed by a unit identifier (e.g., px, em, etc.)."

When the elements are displayed on the screen, most browsers will naturally round the position to the nearest pixel when using 100% zoom level. On higher zoom levels you will notice that fractional pixel values are recognized.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKees C. BakkerView Question on Stackoverflow
Solution 1 - CssGuffaView Answer on Stackoverflow