How to Include a Font .ttf using CSS? Last Updated : 09 Oct, 2024 Comments Improve Suggest changes Like Article Like Report To include a .ttf font in a web project using CSS, you can use the @font-face rule, which allows you to load external fonts and use them throughout your site. Here's a step-by-step guide on how to include a .ttf font using CSS:Steps to include font .ttf using CSS:Step 1: Download a .ttf font file from a free font website, such as Font Squirrel, FontSpace, or Google Fonts. Save the .ttf file in your project folder, preferably in a directory named fonts to keep things organized.Step 2: Set up an HTML file where you will apply the custom font. For example, create an index.html file:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> </head> <body> <h2>This font is awesome</h2> </body> </html>Step 3: Create a style.css file and use the @font-face rule to define the custom font. Specify the font name using the font-family property and the path to the .ttf file using the src property.@font-face { font-family: myFirstFont; src: url(ArianaVioleta-dz2K.ttf); } h2 { font-family: myFirstFont; color: darkgreen; }The ouput should be like this:font in browserExample: In this example, we are trying different font. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> </head> <body> <p>The font on this paragraph looks awesome</p> </body> </html> CSS @font-face { font-family: myFirstFont; src: url(ChrustyRock-ORLA.ttf); } h2 { font-family: myFirstFont; color: darkgreen; } Output: Supported BrowserGoogle ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us Next Article How to Include a Font .ttf using CSS? A atul2002chourasia Follow Improve Article Tags : Web Technologies HTML CSS CSS-Misc HTML-Misc +1 More Similar Reads How to Change Font Size using CSS? The CSS font-size property is used to change the font size of text. CSS font-size PropertyThe font-size property in CSS sets the size of the text of HTML elements. Values can be in pixels, percentages, em, rem etc.Syntaxfont-size: value;Example: We can use various font-size units like - em, smaller, 2 min read How To Add Font In CSS? Adding fonts to a website enhances its design and readability. In CSS, custom fonts can be applied using several techniques that allow web designers to include specific fonts that arenât system defaults.PrerequisitesHTMLCSSThese are the approaches to add a font in CSS: Table of ContentUsing web-safe 2 min read How to use web fonts in CSS ? While designing web pages, developers use different fonts based on what the text represents and which fonts suit the best. Each system comes with some pre-installed fonts which are called system fonts. Since these are limited, one may come across the need to use a different font other than the pre-i 3 min read How to Change Font Style in CSS? Font style is an important element that enhances the readability of the text. CSS provides several properties to change the text appearance and font style. The font style property allows you to define how the text should appear normal, italic, or oblique.Table of ContentDifferent Methods to Change F 3 min read How to Add Custom Fonts in VueJS ? Vue.js is a JavaScript framework used in building powerful and beautiful user interfaces. The key feature of Vue.js is its component-based architecture that allows the developers to create reusable and modular components. Custom fonts can bring uniqueness and visual appeal to your Vue.js application 2 min read Like