×

Font tag in HTML

HTML stands for Hypertext Mark-up Language and is used to create web pages and other information that can be later displayed in a web browser. It also consists of a set of attributes and tags used to define the structures and content of a web page.

What are HTML tags?

HTML tags are used to define the structure and content of a web page. They consist of a tag name enclosed in angle brackets <>, and most tags have a corresponding closing tag with a forward slash /.

For example, the <p> tag is used to define a paragraph, and the text within the tags is the content of the paragraph:

<p>This is the example of a paragraph.</p>

Some tags in HTML do not require a closing tag, such as the <img> tag which is used to embed images in a web page:

<imgsrc="images.jpeg" alt="The image">

HTML tags could also have attributes, which can provide additional information about the tag. For example, the src attribute in the <img> tag points towards the source URL of the image.

Some of the most commonly used HTML tags

Headings: <h1> to <h6>
Paragraphs: <p>
Links: <a>
Images: <img>
Lists: <ul>, <ol>, <li>
Tables: <table>, <tr>, <td>
Forms: <form>, <input>, <textarea>, <button>
Semantic elements: <header>, <nav>, <main>, <aside>, <footer>

Font tag in HTML

The <font> tag in HTML was used to specify the font face, size, and color of text on a web page. This tag was commonly used in the early days of the web when styles were limited and had to be applied directly to individual elements on a page.

However, the <font> tag has been deprecated and is no longer supported in modern HTML (HTML5). It is recommended to use CSS (Cascading Style Sheets) instead to style text and other elements on a web page. CSS provides more control and flexibility over the appearance of a page, and separates the presentation of a page from its content.

For example, instead of using the <font> tag, you can use CSS to set the font family, size, and color for all headings on a page:

h1 { font-family: Arial; font-size: 36px; color: blue; }

The font tag in HTML has several attributes, including:

  • Size: It specifies the size of the text. The size can be specified as an absolute size in points (e.g. size="12") or as a relative size (e.g. size="+2").
  • Color: It specifies the color of the text. The color can be specified as a named color (e.g. color="blue") or as a hexadecimal value (e.g. color="#0000FF").
  • Face: It specifies the typeface of the text. This can be a font family name (e.g. face="Arial").
  • Style: It specifies the font style, such as bold, italic, or normal.

Here is an example of an HTML code using the font tag and its attributes:

Example:

<html>
<body>
<font size="5" color="#0000FF" face="Arial">This is some text!</font>
</body>
</html>

In this example, the size, color, and face attributes are used to specify the font size, color, and typeface of the text.

Note: Note that the font tag is deprecated and it is recommended to use CSS for styling text in HTML documents. Here is an equivalent example using CSS:

Example:

<html>
<head>
<style>
p {
font-size: 20px;
color: blue;
font-family: Arial;
      }
</style>
</head>
<body>
<p>This is some text!</p>
</body>
</html>

In this example, the CSS code is added in the head section of the HTML document, and the p tag is used to define the font size, color, and typeface. The font-size, color, and font-family properties are used to specify the font size, color, and typeface respectively.

Importance of font tag

  • The font tag was used to change the font size and color of text in HTML documents. However, the font tag is now considered deprecated and should not be used in modern HTML development.
  • Instead, CSS is used for styling text in HTML documents, as it provides more control and flexibility in terms of font size, color, and other text styles. CSS allows you to separate the presentation from the content, making it easier to maintain and update the design of a website.
  • So, while the font tag may have had some importance in the past, it is no longer considered a best practice and should not be used in modern HTML development.

Related Topics

HTML SVG

HTML SVG: SVG stands for Scalable Vector Graphics which defines the graphics for the web. It is a language for describing 2-D graphics in XML. Each drawn shape in SVG is...

1 minute read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

HTML Hide Element

The HTML hide element is used to hide the element. We place the hidden attribute inside those elements which we want to hide. The hidden attribute is a Boolean attribute. The...

3 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

Design a tribute page using HTML and CSS

A tribute page is a webpage based on a person who inspired us in our life. In this article, we will create a webpage of Mahatma Gandhi. We are going...

5 minutes read.

HTML Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.

HTML <sup> Tag

The HTML sup element is used to describe one or more superscript contents. The sup tag shows a text which is presented above the regular line and half the length...

2 minutes read.

Html <colgroup> Tag

A HTML table's column group is specified by the "colgroup" tag. If you want to apply various properties to one or more <col> elements in an HTML table, then you...

4 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

Div Tag in HTML

In HTML, ‘div’ is a tag that specifies division or section in HTML document. But before going in detail of it, let’s first understand about tags in HTML. The tag...

8 minutes read.

Html &lt;dd> Tag

In an HTML description list, an item's definition or description is indicated using the definition description ("dd" tag). A <dd> tag can contain paragraphs, line breaks, images, links, and lists. It...

4 minutes read.

HTML5 Button Tag

HTML Button Tag The < button > tag is used on the webpage to construct a clickable button inside the HTML. Within the < button>....</button > tag, we can place content...

2 minutes read.

HTML Background Image

Inserting image in HTML An image (technically digital image) in HTML or even in general technical aspects, is a binary representation of visual information. By visual information we mean, in the...

8 minutes read.

HTML Images

HTML has <img> tag to display image on the web pages or web application. This tag is an empty tag i.e. we don't have to close this tag while using. SYNTAX: <img src="source address" attributes="alt, height, width"> Example: <html>   <body>   <center>Image tag Example</center>   <img src="https://www.tutorialandexample.com/resources/images/favicon.png"    alt="tutorialandexample"/>   </body>   </html> Output: Image...

1 minute read.

HTML Anchor

HTML Anchor The HTML anchor tags define a hyperlink that links to other pages on one page. It can create hyperlinks to any web page and files, locations or any other...

3 minutes read.

HTML Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

4 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

HTML Audio

HTML AUDIO: HTML5 provides a method to embed the audio file into a webpage by using HTML5. Before HTML5 audio files is used to play on the browser with the help of...

1 minute read.

HTML <strike> tag

The HTML <strike> tag is used to specifies strikethrough text. The tag is deprecated now and <del> tag is used in HTML files instead of it. All the global and...

2 minutes read.