HTML <font> Tag - GeeksforGeeks (2024)

Table of Contents
HTML HTML HTML HTML FAQs

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:

<font attribute = "value"> Content </font>

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

HTML

<!DOCTYPE html>

<html>

<body>

<h2>GeeksforGeeks</h2>

<!--Normal paragraph tag-->

<p>Hello Geeks!.</p>

<!--font tag-->

<font size="5"> Welcome to GeeksforGeeks </font>

</body>

</html>

Output:

HTML <font> Tag - GeeksforGeeks (1)

HTML <font> tag

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:

<font size="number">

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

HTML

<!DOCTYPE html>

<html>

<body>

<!--HTML font size tag starts here-->

<font size="1">GeeksforGeeks!</font><br />

<font size="2">GeeksforGeeks!</font><br />

<font size="3">GeeksforGeeks!</font><br />

<font size="4">GeeksforGeeks!</font><br />

<font size="5">GeeksforGeeks!</font><br />

<font size="6">GeeksforGeeks!</font><br />

<font size="7">GeeksforGeeks!</font>

<!--HTML font size tag ends here-->

</body>

</html>

Output:

HTML <font> Tag - GeeksforGeeks (2)

font size attribute

Font Type: Font type can be set by using face attribute with font tag in HTML document. But the fonts used by the user need to be installed in the system first.

Syntax:

<font face="font_family">

Example: This example describes the <font> tag with different font type & font size.

HTML

<!DOCTYPE html>

<html>

<body>

<!--HTML font face tag starts here-->

<font face="Times New Roman" size="6">

GeeksforGeeks!!

</font> <br />

<font face="Verdana" size="6">

GeeksforGeeks!!

</font><br />

<font face="Comic sans MS" size=" 6">

GeeksforGeeks!!

</font><br />

<font face="WildWest" size="6">

GeeksforGeeks!!

</font><br />

<font face="Bedrock" size="6">

GeeksforGeeks!!

</font><br />

<!--HTML font face tag ends here-->

</body>

</html>

Output:

HTML <font> Tag - GeeksforGeeks (3)

font type attribute

Font Color: Font color is used to set the text color using a font tag with the color attribute in an HTML document. Color can be specified either with its name or with its hex code.

Syntax:

<font color="color_name|hex_number|rgb_number">

Example: This example describes the <font> tag with different font colors.

HTML

<!DOCTYPE html>

<html>

<body>

<!--HTML font color tag starts here-->

<font color="#009900">GeeksforGeeks</font><br />

<font color="green">GeeksforGeeks</font>

<!--HTML font color tag ends here-->

</body>

</html>

Output:

HTML <font> Tag - GeeksforGeeks (4)

font color attribute

Supported Browsers:

  • Google Chrome
  • Microsoft Edge 12 and above
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

My Personal Notesarrow_drop_up

HTML <font> Tag - GeeksforGeeks (2024)

FAQs

What is the font tag in HTML? ›

The <font> tag was used in HTML 4 to specify the font face, font size, and color of text.

What is the difference between base font and font tag? ›

Basefont tag is used to define default font, size and color for the whole text in an html document. On the other hand font tag is used to define font, size, color etc for a text which enclosed with in this tag. On the other hand you have to enclose the text within the font tag to apply changes.

What is the HTML tag for font size? ›

In HTML, you can change the size of text with the <font> tag using the size attribute. The size attribute specifies how large a font will be displayed in either relative or absolute terms. Close the <font> tag with </font> to return to a normal text size.

Why is font tag deprecated? ›

The <font> Tag (Deprecated) The <font> tag lets you change the size, style, and color of text. We don't recommend that you use it, because it has been deprecated in the HTML 4 and XHTML standards, even though all the popular browsers still support it.

What are the 3 attributes of font tag in HTML? ›

The font tag is having three attributes called size, color, and face to customize your fonts.

How do I use different fonts in HTML? ›

How to Change Font Type in HTML. To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.

What are the different types of 3 font? ›

Some of the most popular types of fonts include serif, sans serif, slab serif, script and decorative.

How do I change the font tag in HTML? ›

To change the text font in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-family, font-size, font-style, etc. HTML5 do not support the <font> tag, so the CSS style is used to change font.

What are the best HTML font sizes? ›

Body fonts should be about 16px

Start with 16px. Consider going smaller if you have (A) have an interaction-heavy page or (B) a font with particularly large, easy-to-read characters (like Proxima Nova in the image above)

Which HTML tag is the largest size font? ›

There are 6 gradings or levels of HTML headings: <h1> to <h6> . Graphically, these create decreasingly large text, with h1 being the biggest, and h6 being the smallest of the group.

What is the default HTML font and size? ›

Default HTML Font Size Values

With no work applied to the page, the HTML font size will be set at its default value of 16px. If you are not familiar with that expression, the number is the size and the “px” is the shorthand for pixels.

What replaced the font tag in HTML5? ›

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.

Is font tag still used? ›

Note: The font tag in HTML is no longer used. The font tag is deprecated in HTML5, so we can use the CSS properties to change the font size, face, color, font, font-family, font-size, etc..

Why should the font tag not be used in HTML? ›

Because HTML aims to be semantic, i.e. describe what should be presented. The font tag has absolutely no semantic meaning, it is purely mechanical: it describes how something should be presented. The way to control the mechanics of presentation is CSS, not HTML.

What are the 4 essential tags in HTML? ›

There is a range of HTML tags, they help you to design your web page. There are four required tags in HTML. These are html, title, head and body.

What are the 3 types of style in HTML? ›

CSS can be added to HTML documents in 3 ways:
  • Inline - by using the style attribute inside HTML elements.
  • Internal - by using a <style> element in the <head> section.
  • External - by using a <link> element to link to an external CSS file.

How do I change font size and color in HTML? ›

You can change the color and size of your text right inside its tag with the color and font-size properties. This is known as inline CSS. You do it with the style attribute in HTML.

How do I know if a font is loaded in HTML? ›

FontFaceSet: check() method

The check() method of the FontFaceSet returns true if you can render some text using the given font specification without attempting to use any fonts in this FontFaceSet that are not yet fully loaded. This means you can use the font specification without causing a font swap.

How do you know if text is bold or italic in HTML? ›

HTML Formatting Elements

Formatting elements were designed to display special types of text: <b> - Bold text. <strong> - Important text. <i> - Italic text.

What font does Google use? ›

Product Sans is a contemporary geometric sans-serif typeface created by Google for branding purposes. It replaced the old Google logo on September 1, 2015.

How many types of HTML tags are there? ›

There are two kinds of HTML tags: paired and unpaired. Paired tags require an opening tag that turns a formatting feature on and a closing tag that turns the feature off. Paired tags must surround the text you want formatted with that feature.

Where do I link fonts in HTML? ›

➕ Add Custom Font(s) to your Website
  • Copy/paste the <link> tag displayed in the “Embed Font” section into your HTML <head> tag.
  • Then, on your CSS stylesheet add the line displayed in the “Specify in CSS” section to the class or selector that corresponds to your text.

How do I identify a font? ›

If the font you want to identify is in printed material like a magazine, you can find the name with a scanned image. Once you have a digital image, you can upload the image to a website like WhatTheFont. WhatTheFont 'reads' the font in your image and compares it to thousands it holds in its database.

What are the 4 main fonts? ›

Learning about the four main font categories—Serif, Sans Serif, Display, and Script—is an excellent place to start.

What are the 5 main types of fonts? ›

There are five basic classifications of typefaces: serif, sans serif, script, monospaced, and display.

What is small font size in HTML? ›

HTML <small> Tag. The <small> tag decreases the text font size making it one size smaller than a document's base font size (from medium to small, or from x-large to large).

What is the U tag? ›

<u>: The Unarticulated Annotation (Underline) element. The <u> HTML element represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation. This is rendered by default as a simple solid underline, but may be altered using CSS.

How do I change my font style? ›

Click Format > Text Styles. In the Item to Change list, click All, then select the font, size, or color you want for all text in the current view.

What color font should you use? ›

Black text on a white background provides maximal value contrast and, therefore, optimal readability for body text. Black text on a white background provides maximal value contrast and, therefore, optimal readability for body text.

Which HTML tag is smallest heading? ›

<h1>–<h6>: The HTML Section Heading elements

<h1> is the highest section level and <h6> is the lowest.

How do you change font color in HTML? ›

You can use the CSS color property to change the text color. This property accepts color values like Hex codes, RGB, HSL, or color names.

What is the default font color in HTML? ›

There is no default color defined in HTML. The "default color" is configured in the browser or by the operating system you are using.

What is the size of h1 tag in HTML? ›

HTML h1 tag <h1>

Default Font size of h1 element is 2em.

What is the size attribute in HTML? ›

Definition and Usage

For input elements, the size attribute specifies the visible width, in characters, of an <input> element. For select elements, the size attribute specifies the number of visible options in a drop-down list.

Which tags are discontinued in HTML? ›

Some attributes from HTML4 are no longer allowed in HTML5 at all and they have been removed completely. img and iframe. caption, iframe, img, input, object, legend, table, hr, div, h1, h2, h3, h4, h5, h6, p, col, colgroup, tbody, td, tfoot, th, thead and tr. table, tr, td, th and body.

What tags are deprecated in HTML? ›

HTML - Deprecated Tags
TagDescriptionAlternate
<embed>Deprecated. Embeds an application in a document<object>
<font>Deprecated. Specifies text font, size, and colorfont-family, font-size
<isindex>Deprecated. Specifies a single-line input field
<listing>Deprecated. Specifies listing of items<pre>
10 more rows

What is the deprecated font tag in HTML5? ›

The <tt> tag, used in HTML4 to apply a monospaced (fixed width) font to the text, was deprecated in HTML5. Instead, you should use CSS to apply the desired font. The <table> element does not accept a height attribute.

What is one of the fonts to avoid? ›

Courier, initially designed for typewriters, is another family of fonts that falls on the overused list. Designers and branding agencies avoid this font, primarily due to its improperly measured lettering.

What is the most commonly used font type today? ›

Sans serif fonts are the most common and most versatile of the main types of fonts. In the digital world sans serif fonts are the font of choice for thousands of brands globally, thanks to their clarity, legibility, and simplicity. Take these famous sans serif logos for example!

Is I tag obsolete? ›

In HTML5 i and b are no longer deprecated. Instead, they are given sematic meaning. So they are now actually about semantics, and not about presentation. As before, you use em to mark up emphasis: "The cat is mine." But you use i for almost all other cases where you would use italics in a printed work.

When was font tag deprecated? ›

The font element was deprecated in HTML 4.01. The font element should not be supported in HTML 5, but is allowed when inserted by a WYSIWIG editor. Only the style attribute is supported in HTML 5.

Is it better to import fonts in CSS or HTML? ›

Loading Google fonts in the HTML reduces the critical request depth and speeds up page load Always import your fonts from HTML, not CSS.

Can we embed a font in HTML? ›

It's possible to supply multiple src attributes. This way, you can include both an EOT and OTF version of a font so that it will work on a wide variety of browsers. When you use this technique, you need to have a copy of the font file locally. It should be in the same directory as your web page.

What is font vs text in HTML? ›

"The 'text-' properties are working rendered text without modifying of the characters geometry. The 'font-' properties are working with raw characters and imparts the specific form to them".

Is font tag an empty tag? ›

The <font> tag is a container tag. Using size attribute you can set font size. Valid values is from 1 (smallest size) to 7 (largest size).

How do I use HTML font and style? ›

Chapter Summary
  1. Use the style attribute for styling HTML elements.
  2. Use background-color for background color.
  3. Use color for text colors.
  4. Use font-family for text fonts.
  5. Use font-size for text sizes.
  6. Use text-align for text alignment.

Is text the same as font? ›

Overview​ Texts are written characters, while fonts are the text's styles.

What is the difference between font and type font? ›

The main difference between these two terms is that a typeface (or type family) is the name of a specific collection of related fonts. In comparison, font refers to a particular weight, width, and style within that typeface. To put it in simple terms, each variation of a typeface is a font.

What is the default font in HTML5? ›

Save this answer. Show activity on this post. In browsers I use (Chrome, Opera, Firefox) default fonts are: Standard font: Times New Roman, Serif font: Times New Roman, Sans-serif font: Arial, Monospaced or fixed-width: Consolas (Firefox: Courier New).

What are 3 examples of empty tags? ›

Some examples of empty tags are img, embed, area, meta, link, etc. The empty elements are those elements of HTML that cannot have some content like text or child element inside them.

Does font tag need to be closed? ›

The <font> tag is used to specify the text font size, color and font name. The text is placed between the opening and closing font tags.

Top Articles
Latest Posts
Article information

Author: Rob Wisoky

Last Updated:

Views: 5909

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.