HTML Font Tag | Using HTML Font - Example of how you might use CSS to achieve similar effects with HTML Font Tag

HTML Font Tag:

The `<font>` tag was historically used in HTML to define the font, color, and size of text. However, it has been deprecated in HTML5, and its usage is strongly discouraged. Instead, it is recommended to use Cascading Style Sheets (CSS) for styling purposes.


Using HTML Font - Example of how you might use CSS to achieve similar effects with HTML Font Tag
HTML Font Tag

Here's an example of how you might use CSS to achieve similar effects:

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Styled Text</title>
  <style>
    /* CSS styling */
    .custom-text {
      font-family: Arial, sans-serif;
      color: blue;
      font-size: 18px;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <!-- HTML content with CSS class -->
  <p class="custom-text">This text is styled using CSS.</p>
</body>
</html>

In this example, the CSS within the `<style>` element is used to define a class called `custom-text`. This class is then applied to a paragraph (`<p>`) element in the HTML. The CSS properties within the class define the font family, color, size, and weight of the text.

It's good practice to use external CSS files for styling in real-world projects rather than embedding styles directly in the HTML document. The `<font>` tag is no longer considered standard, and CSS provides a more flexible and maintainable way to style web content.
ShowHideComments