Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 648605 of <font>

  • Revision slug: Web/HTML/Element/font
  • Revision title: <font>
  • Revision id: 648605
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{obsolete_header}}

Summary

The HTML Font Element (<font>) defines the font size, color and face for its content.

Usage note: 

Do not use this element! Though once normalized in HTML 3.2, it was deprecated in HTML 4.01, at the same time as all elements related to styling only, then obsoleted in HTML5.

Starting with HTML 4, HTML does not convey styling information anymore (outside the {{HTMLElement("style")}} element or the style attribute of each element). For any new web development, styling should be written using CSS only.

The former behavior of the {{HTMLElement("font")}} element can be achieved, and even better controlled using the {{CSS_Reference:Fonts}} CSS properties.

Attributes

Like all other HTML elements, this element supports the global attributes.

{{htmlattrdef("color")}}
This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.
{{htmlattrdef("face")}}
This attribute contains a comma-sperated list of one or more font names. The document text in the default style is rendered in the first font face that the client's browser supports. If no font listed is installed on the local system, the browser typically defaults to the proportional or fixed-width font for that system.
{{htmlattrdef("size")}}
This attribute specifies the font size as either a numeric or relative value. Numeric values range from 1 to 7 with 1 being the smallest and 3 the default. It can be defined using a relative value, like +2 or -3, which set it relative to the value of the {{htmlattrxref("size", "basefont")}} attribute of the {{HTMLElement("basefont")}} element, or relative to 3, the default value, if none does exist.

DOM interface

This element implements the {{domxref("HTMLFontElement")}} interface.

Browser compatibility

Gecko notes

Prior to Gecko 15.0 {{geckoRelease("15.0")}}, Gecko did not handle out-of-bounds values for the size attribute correctly; it would not accept any out-of-bounds values for relative sizes. Now it correctly truncates these into the range -10 to +10.

Gecko 15.0 also removes support for font-weight and point-size attributes on the <font> element; these were non-standard and Gecko was the only engine supporting them.

{{HTMLRef}}

Revision Source

<div>
 {{obsolete_header}}</div>
<h2 id="Summary">Summary</h2>
<p>The <em>HTML Font Element</em> (<span style="font-family: Courier New;">&lt;font&gt;</span>) defines the font size, color and face for its content.</p>
<div class="note">
 <p><em>Usage note:&nbsp;</em></p>
 <p><strong>Do not use this element! </strong>Though once normalized in HTML 3.2, it was deprecated in HTML 4.01, at the same time as all elements related to styling only, then obsoleted in HTML5.</p>
 <p>Starting with HTML 4, HTML does not convey styling information anymore (outside the {{HTMLElement("style")}} element or the <strong>style</strong> attribute of each element). For any new web development, styling should be written using <a href="/en-US/docs/CSS" title="CSS">CSS</a> only.</p>
 <p>The former behavior of the {{HTMLElement("font")}} element can be achieved, and even better controlled using the {{CSS_Reference:Fonts}} CSS properties.</p>
</div>
<h2 id="Attributes">Attributes</h2>
<p>Like all other HTML&nbsp;elements, this element supports the <a href="/en-US/docs/HTML/Global_attributes" title="HTML/Global attributes">global attributes</a>.</p>
<dl>
 <dt>
  {{htmlattrdef("color")}}</dt>
 <dd>
  This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.</dd>
 <dt>
  {{htmlattrdef("face")}}</dt>
 <dd>
  This attribute contains a comma-sperated list of one or more font names. The document text in the default style is rendered in the first font face that the client's browser supports. If no font listed is installed on the local system, the browser typically defaults to the proportional or fixed-width font for that system.</dd>
 <dt>
  {{htmlattrdef("size")}}</dt>
 <dd>
  This attribute specifies the font size as either a numeric or relative value. Numeric values range from <span style="font-family: Courier New;">1</span> to <span style="font-family: Courier New;">7</span> with <span style="font-family: Courier New;">1</span> being the smallest and <span style="font-family: Courier New;">3</span> the default. It can be defined using a relative value, like <span style="font-family: Courier New;">+2</span> or <span style="font-family: Courier New;">-3</span>, which set it relative to the value of the {{htmlattrxref("size", "basefont")}} attribute of the {{HTMLElement("basefont")}} element, or relative to <span style="font-family: Courier New;">3</span>, the default value, if none does exist.</dd>
</dl>
<h2 id="DOM_interface">DOM interface</h2>
<p>This element implements the {{domxref("HTMLFontElement")}} interface.</p>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<h3 id="Gecko_notes">Gecko notes</h3>
<p>Prior to Gecko 15.0 {{geckoRelease("15.0")}}, Gecko did not handle out-of-bounds values for the <code>size</code> attribute correctly; it would not accept any out-of-bounds values for relative sizes. Now it correctly truncates these into the range -10 to +10.</p>
<p>Gecko 15.0 also removes support for <code>font-weight</code> and <code>point-size</code> attributes on the <code>&lt;font&gt;</code> element; these were non-standard and Gecko was the only engine supporting them.</p>
<div>
 {{HTMLRef}}</div>
Revert to this revision