Что такое font в html
Перейти к содержимому

Что такое font в html

  • автор:

Что такое font в html

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The <font> HTML element defines the font size, color and face for its content.

Warning: Do not use this element. Use the CSS Fonts properties to style text.

Attributes

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

This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format.

This attribute contains a comma-separated 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.

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 sets it relative to 3 , the default value.

Что такое font в html

Свойство font универсальное свойство, которое позволяет одновременно задать несколько характеристик шрифта и текста.

  • font

Синтаксис¶

Значения¶

В качестве обязательных значений свойства font указывается размер шрифта и его семейство. Остальные значения являются опциональными и задаются при желании. Для подробного ознакомления смотрите информацию о каждом свойстве отдельно.

Допускается в качестве значения использовать ключевые слова, определяющие шрифт различных элементов операционной системы пользователя.

caption Шрифт для текста элементов форм вроде кнопок. icon Шрифт для текста под иконками. menu Шрифт применяемый в меню. message-box Шрифт для диалоговых окон. small-caption Шрифт для подписей к небольшим элементам управления. status-bar Шрифт для строки состояния окон.

Значение по-умолчанию: зависит от использования

Применяется ко всем элементам

Спецификации¶

Описание и примеры¶

Из типографики пошла запись указывать через слэш размер шрифта и высоту строки. Поэтому 12pt в данном случае означает размер основного текста в пунктах, а 10pt — высоту строки. В качестве семейства указывается рубленый шрифт ( sans-serif ).

Значение bold устанавливает жирное начертание текста, а italic — курсивное. В данном случае их порядок не важен, поэтому bold и italic можно поменять местами. Размер текста задаётся в процентах, а в качестве гарнитуры используется шрифт с засечками ( serif ).

Значение small-caps принадлежит свойству font-variant и устанавливает текст в виде капители (заглавные буквы уменьшенного размера). Значение normal применяется сразу к двум свойствам: font-style и font-weight .

Что такое font в html

The <font> tag in HTML plays an important role in the web page to create an attractive and readable web page. The font tag is used to change the color, size, and style of a text. The base font tag is used to set all the text to the same size, color and face.

Syntax:

Example: In this example, we have used the <font> tag with a font size as 5.

Output:

The font tag has basically three attributes which are given below:

Note: Font tag is not supported in HTML5.

We will discuss all these attributes & understand them through the examples.

font Size: This attribute is used to adjust the size of the text in the HTML document using a font tag with the size attribute. The range of size of the font in HTML is from 1 to 7 and the default size is 3.

Syntax:

Example: This example uses the <font> tag where different font sizes are specified.

HTML: <font> tag

This HTML tutorial explains how to use the HTML element called the <font> tag with syntax and examples.

Description

The HTML <font> tag defines the font size, color and face of text in the HTML document. Since this tag was removed in HTML5, it is recommended that you use CSS properties such as font, font-family, font-size and color to format the text in the document. This tag is also commonly referred to as the <font> element.

Syntax

In HTML, the syntax for the <font> tag is: (example that formats the text as red, uses to the font-family Verdana, Geneva, sans-serif and has a relative size of +1)

Sample Output

Attributes

In addition to the Global Attributes, the following is a list of attributes that are specific to the <font> tag:

Attribute Description HTML Compatibility
color Color of text in either hexadecimal (ie: #RRGGBB format) or named color (ie: black, red, white) HTML 4.01
face Font to use for text. Listed as one or more font names (comma separated) HTML 4.01
size Font size expressed as either a numeric or relative value.

  • The HTML <font> element is found within the <body> tag.
  • The <font> tag is obsolete in HTML5. Use CSS instead to format the text. The CSS equivalents would be color, font, font-family, font-size, etc.

Browser Compatibility

The <font> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <font> tag below, exploring examples of how to use the <font> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.

  • HTML5
  • HTML4
  • XHTML

HTML5 Document

You can not use the <font> tag in HTML5. Instead, use CSS properties such as font, font-family, font-size and color to format the text in the document.

HTML 4.01 Transitional Document

If you created a new web page in HTML 4.01 Transitional, your <font> tag might look like this:

In this HTML 4.01 Transitional Document example, we have 6 <font> tag examples.

The first <font> tag shows how to set the font color with a named color while the second <font> tag shows how to set the font color with a hexadecimal value. The third <font> tag shows how to set the font face with a comma separate list of font families to use. The fourth <font> tag shows how to set the font size using a numeric value while the fifth <font> tag shows how to set the font size using a relative value.

The sixth <font> tag shows how to combine the color, face, and size together in the same <font> tag.

XHTML 1.0 Transitional Document

If you created a new web page in XHTML 1.0 Transitional, your <font> tag might look like this:

In this XHTML 1.0 Transitional Document example, we have 6 <font> tag examples.

The first <font> tag shows how to set the font color with a named color while the second <font> tag shows how to set the font color with a hexadecimal value. The third <font> tag shows how to set the font face with a comma separate list of font families to use. The fourth <font> tag shows how to set the font size using a numeric value while the fifth <font> tag shows how to set the font size using a relative value.

The sixth <font> tag shows how to combine the color, face, and size together in the same <font> tag.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *