Font size in pixels

Point sizes are defined as 1/72 of an inch. That is, a 72-point font is approximately 1 inch from the lowest descent to the highest ascent. So the maximum height of a glyph in a 72pt font is about 1 inch. Apple’s iphone tech specs page claims that the iPhone currently has a resolution of … Read more

Responsive Typography in Material UI?

Update MUI v4 has responsive typography built in! Check here for details. Old response @Luke’s answer is great. I wanted to add some detail to make this work in practice, because both breakpoints and pxToRem are accessible on the theme object… making this becomes a chicken and egg problem! My approach: import { createMuiTheme } … Read more

H1-H6 font sizes in HTML

Update: Nowadays, modern browsers use these values. Original answer: They are defined by each browser maker independently. They are not uniform across browsers and are there for semantics (Large header, slightly smaller header etc…). If you look at the HTML 4 specification for these, there no mention of how they are supposed to be styled, … Read more

What is the proper HTML entity for the “x” in a dimension?

× Unicode: U+00D7 MULTIPLICATION SIGN HTML: ×, × CSS: \00d7 See the Wikipedia article about the multiplication sign: In mathematics, the symbol × (read as times or multiplied by) is primarily used to denote the […] Geometric dimension of an object, such as noting that a room is 10×12 feet in area. Depending on the … Read more

Force Non-Monospace Font into Fixed Width Using CSS

If this is for aligning digits in tables where some fonts (with traditional typography) render them by default with variable width (e.g. Segoe UI on Windows), you should look into CSS properties for: font-variant-numeric: tabular-nums; (this disables the proportional-nums default value for the numeric-spacing variant supported at least by OpenType fonts, and possibly by other … Read more

How do I style HTML5 canvas text to be bold and/or italic?

From the MDN documentation on CanvasRenderingContext2D.font: The CanvasRenderingContext2D.font property of the Canvas 2D API specifies the current text style to use when drawing text. This string uses the same syntax as the CSS font specifier. So, that means any of the following will work: ctx.font = “italic 10pt Courier”; ctx.font = “bold 10pt Courier”; ctx.font … Read more

How to properly set line height for Android?

I’ll explain this from Android Developer perspective. Line height usually means text size + “padding” top/bottom. So, if your designer write line height 19sp and text size 15sp, it means you need to have extra padding 4sp. 19sp – 15sp = 4sp. To implement it in your layout, use lineSpacingExtra attribute. <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textSize=”15sp” … Read more