David
David

Reputation: 560

What's the meaning of the font-weight integer values in CSS?

In CSS it's possible to set the font-weight to normal, bold, bolder, lighter, inherit and plane integer values from 100-900. Now my question is: Why are there such possible integer values? Why don't we have the listed property string values and who got that idea to use that integer values and why exactly these and not from 1-9?

Upvotes: 3

Views: 3215

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201876

Regarding the question in the title: The integer values of font-weight denote different possible font weights of typefaces, and they may need to be re-interpreted if the font format does not have a scale of 9 font weights. For the TrueType format, the value is the one assigned to the typeface in the OS/2 table, item usWeightClass.

Typefaces typically have names with attributes like “regular”, “light”, “heavy”, “bold”, etc. The use of such words varies, though CSS3 Fonts describes a “rough correspondence” between numbers and names.

The numbers constitute an ordinal scale only; e.g., the only thing we can say about typefaces with weights 100 and 200 is that the latter is not lighter tan the former. The correspondence between a number and the “blackness” or stroke width of characters is font-dependent.

The value normal equals 400 by definition, and the value bold equals 700 by definition. These are just keywords available in CSS as alternatives to the two numbers.

The values bolder and lighter are relative to the font weight of the parent; they map numeric values to larger or smaller values, respectively. So they do not constitute new weights.

The value inherit means that the value of a property is to be set equal to the value of the property of the parent element.

So the only real weights are the nine values from 100 to 900. For most fonts commonly used on web pages, only a few of these weights are available (most often just 400 and 700, or maybe just 400).

Regarding “Why are there such possible integer values?”, a scale of 9 weights was considered sufficient – fonts just don’t have more weights than that.

Regarding “Why don't we have the listed property string values”, the numbers are neutral and can be used independently of the naming scheme used for a font.

Regarding “why exactly these and not from 1-9”, the scale 100, 200,... allows the introduction of intermediary weights – just in case some font designer some day wants to spend time in designing more than nine typefaces. The somewhat strange numbering scheme would allow the introduction of a more fine-grained scale later.

Upvotes: 4

SLaks
SLaks

Reputation: 888205

This nomenclature is inherited from TrueType fonts.

Quoting Wikipedia:

The TrueType font format introduced a scale from 100 through 900, where 400 is regular (roman or plain), which is also used in CSS and OpenType. The first algorithmic description of fonts was perhaps made by Donald Knuth in his Metafont and TeX system of programs.

Upvotes: 2

Related Questions