Thẻ <basefont> đã lỗi thời (deprecated) từ HTML4 và không được hỗ trợ trong HTML5. Không nên dùng. Thay thế bằng CSS.
Ví dụ cũ (chỉ để tham khảo lịch sử)
<!DOCTYPE html> <html> <head> <title>HTML basefont Tag</title> </head> <body> <basefont face="cursive,serif" color="blue" size="5" /> </body> </html>
Cách hiện đại: CSS
<!DOCTYPE html>
<html>
<head>
<style>
/* Font cơ sở cho toàn trang */
html {
font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333;
}
/* Hoặc dùng CSS custom properties */
:root {
--font-base: "Inter", sans-serif;
--font-size-base: 1rem;
}
body { font-family: var(--font-base); font-size: var(--font-size-base); }
</style>
</head>
<body>
<p>Văn bản dùng font cơ sở từ CSS.</p>
</body>
</html>
Ưu điểm CSS so với <basefont>
- Tách biệt cấu trúc (HTML) và trình bày (CSS).
- Hỗ trợ responsive (media query), variable font, font-weight/width tùy chỉnh.
- Kế thừa tự nhiên, dễ override cho component con.
- Hiệu năng tốt hơn (browser optimize CSS).