HOME

TheInfoList



OR:

The font family selection in (X)HTML,
CSS Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
, and derived systems specifies a list of prioritized fonts and generic family names; in conjunction with correlating font properties, this list determines the particular font face used to render characters. The family selection is available in two forms: in the deprecated (X)HTML element with its attribute, and in the
CSS Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
property. The CSS term ''font family'' is matched with the typographical term ''
typeface A typeface (or font family) is the design of lettering that can include variations in size, weight (e.g. bold), slope (e.g. italic), width (e.g. condensed), and so on. Each of these variations of the typeface is a font. There are list of type ...
'', which is a grouping of fonts defined by shared design styles. A ''
font In metal typesetting, a font is a particular size, weight and style of a typeface. Each font is a matched set of type, with a piece (a "sort") for each glyph. A typeface consists of a range of such fonts that shared an overall design. In mod ...
'' is a particular set of ''glyphs'' (character shapes), differentiated from other fonts in the same family by additional properties such as stroke weight, slant, relative width, etc. The CSS term ''font face'' is matched with "font"; it is decided by a combination of the font family and the additional properties. In both HTML and CSS, the list is separated by commas. To avoid unexpected results, the last font family on the font list should be one of the generic families which are by default always available. In the absence of a font being found, the web browser will use its default font, which may be a user-defined one. Depending on the web browser, a user can in fact override the font defined by the code writer. This may be for personal taste reasons, but may also be because of some physical limitation of the user, such as the need for a larger font size or the avoidance of certain colors. In addition to local fonts, modern web browsers support linking custom font files directly by using the @font-face declaration. Once included, such fonts can be listed in the font-family property, alongside all local and fallback fonts.


Examples

The following example defines the same font face (
Times Time is the continued sequence of existence and events, and a fundamental quantity of measuring systems. Time or times may also refer to: Temporal measurement * Time in physics, defined by its measurement * Time standard, civil time specific ...
or a default
serif In typography, a serif () is a small line or stroke regularly attached to the end of a larger stroke in a letter or symbol within a particular font or family of fonts. A typeface or "font family" making use of serifs is called a serif typeface ...
, 14 points, italics) in three ways: * With
CSS Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
in a separate stylesheet. * With inline
CSS Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
applied to an element via the attribute. * With the
deprecated In several fields, especially computing, deprecation is the discouragement of use of some terminology, feature, design, or practice, typically because it has been superseded or is no longer considered efficient or safe, without completely removing ...
presentational element and its non-standard attribute . ( is not deprecated in general, but its presentational use is.) .text

Sample text formatted with CSS in a separate stylesheet.

Sample text formatted with inline CSS.

Sample text formatted with the deprecated FONT tag.

It is a
best practice A best practice is a method or technique that has been generally accepted as superior to other known alternatives because it often produces results that are superior to those achieved by other means or because it has become a standard way of doing ...
to put a space after the comma, and to put any name containing spaces between quotation marks.


Font name as family name

Although CSS tries to define a font family as the same as a typeface, the entry and its non-standard HTML predecessor has also historically been used to identify the entire ''font face''. This usage is due to
font file A computer font is implemented as a digital data file containing a set of graphically related glyphs. A computer font is designed and created using a font editor. A computer font specifically designed for the computer screen, and not for print ...
s not describing themselves as part of a family, partially motivated by the fact that few editors at the time supported the selection among more than four font styles (bold/regular and italics/regular). As a result, it used to be common to see declarations such as in place of the pedantically correct . Neither CSS2 nor CSS3 endorse such a use (they are not found in examples), but most browsers accept them as valid "names" nevertheless.


Generic fonts

The ''font-family'' can use a specific named font (like ''Heisei Mincho W9''), but the result depends on the fonts installed on the user machine. The actual appearance will depend on the browser and the fonts installed on the system. A default installation of
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements current and ...
on
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
, for instance, will display both ''serif'' as
Times New Roman Times New Roman is a serif typeface. It was commissioned by the British newspaper ''The Times'' in 1931 and conceived by Stanley Morison, the artistic adviser to the British branch of the printing equipment company Monotype, in collaboration wit ...
, and both ''sans-serif'' as
Arial Arial (also called Arial MT) is a sans-serif typeface and set of computer fonts in the neo-grotesque style. Fonts from the Arial family are included with all versions of Microsoft Windows from Windows 3.1 on, some other Microsoft software appli ...
. Usually only a small subset of them, chiefly the Serif, Sans-serif, Monospace and Cursive are easily configurable by user in web browsers. Many systems also perform special-cased ''font substitution'' to replace missing "well-known" families with
metric-compatible A typeface (or font family) is the design of lettering that can include variations in size, weight (e.g. bold), slope (e.g. italic), width (e.g. condensed), and so on. Each of these variations of the typeface is a font. There are thousands o ...
alternatives. For example, Windows substitutes ''Helvetica'' with Arial, and ''Times'' with Times New Roman. These families are not generic in the CSS sense, and are generally not handled at the browser level.


See also

*
Core fonts for the Web Core fonts for the Web was a project started by Microsoft in 1996 to create a standard pack of fonts for the World Wide Web. It included the proprietary fonts Andalé Mono, Arial, Arial Black, Comic Sans MS, Courier New, Georgia, Impact, Times Ne ...
*
List of typefaces This is a list of typefaces, which are separated into groups by distinct artistic differences. The list includes typefaces that have articles or that are referenced. Superfamilies that fall under more than one category have an asterisk (*) after t ...
* Presentational markup *
Web typography Web typography is the use of fonts on the World Wide Web. When HTML was first created, font faces and styles were controlled exclusively by the settings of each web browser. There was no mechanism for individual Web pages to control font display u ...


Notes

{{DEFAULTSORT:Font family HTML Typesetting