Phenomenon
When applying font sizes in Chrome, the units (px, em, rem) may be converted inconsistently. Relative units may be converted to absolute units, or vice versa, making it difficult to maintain consistent sizing.
Reproduction example
- Apply font size with em unit:
font-size: 1.2em - Edit the text or apply other formatting
- Observe the font-size value
Observed behavior
- Units may be converted:
1.2embecomes19.2px - Or units may be preserved
- Conversion is inconsistent
- Relative sizing is lost
Expected behavior
- Units should be preserved as specified
- Or conversion should be predictable
- Relative units should remain relative
- Behavior should be consistent
Browser Comparison
- Chrome/Edge: May convert units (this case)
- Firefox: Similar conversion behavior
- Safari: Unit handling varies
Notes and possible direction for workarounds
- Preserve original units explicitly
- Convert units only when necessary
- Document unit conversion behavior
- Consider using data attributes to store original units