How to add a base font in a HTML page?


The HTML <basefont> tag specifies the standard font-family, font-size, and colour for the text in the HTML document. It is advised that you format the text in the document using CSS attributes like font, font-family, font-size, and colour since this tag was deleted in HTML5.

Note − Not supported in HTML5

Syntax

<basefont color=”..” size=".." face="..">

Following are the examples…

Example: Instead using CSS (basefont is not supported by html5)

In the following example we are using css style to allow basefont as it was alternative of it.

<!DOCTYPE html> <html> <head> <style> body { text-align: center; } .varma { color: green; font-size: 45px; font-family: sans-serif; } .varma1 { font-family: arial; } </style> </head> <body> <div class="varma">TUTORIALSPOINT</div> <div class="varma1"> A Learning portal for Everyone. It contains well written,<br>well thought and well explained computer science and programming articles. </div> </body> </html>

Output

When the script gets executed, it will display text according to the font style which we mentioned inside the <style> tag of the above script.

Updated on: 05-Sep-2022

342 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements