How to add custom font in asp net mvc 5


ASP.NET is a popular programming language used for web applications. In this article, we will discuss how to add a custom font in ASP.NET MVC 5.

Step 1: Download the Font

The first step is to download the custom font that you want to use in your ASP.NET MVC 5 application. You can find various websites that offer free and paid fonts. Once you have downloaded the font file, make sure to extract it if it is in a compressed .

Step 2: Add the Font File to Your Project

Next, you need to add the font file to your ASP.NET MVC 5 project. To do this, follow these steps:

  1. Right- on your project in Visual Studio and select “Add” > “Existing Item”.
  2. Navigate to the location where you saved the font file and select it.
  3. Click on the “Add” button to add the font file to your project.

Step 3: Set the Build Action

After the font file to your project, you need to set the build action to “”. This will ensure that the font file is in the published output of your ASP.NET MVC 5 application.

To set the build action, follow these steps:

  1. Right-click on the font file in Visual Studio.
  2. Select “Properties” from the context menu.
  3. In the properties , set the “Build Action” property to “Content”.

Step 4: Reference the Font in CSS

Now that you have added the font file to your project, you can reference it in your CSS file. Open your CSS file and add the following code:

@font-face {
  font-family: 'CustomFont';
  src: url('../fonts/your-font-file.ttf') format('truetype');

Make sure to replace “your-font-file.ttf” with the actual file name of your font.

Step 5: the Font to Your HTML

Once you have defined the font in your CSS file, you can apply it to your HTML elements. To do this, use the “font-family” property in your CSS . For example:

h1 {
  font-family: 'CustomFont', sans-serif;

This will apply the custom font to all h1 elements in your ASP.NET MVC 5 application.


Adding a custom font to your ASP.NET MVC 5 application is a simple process. By following the steps outlined in this article, you can easily incorporate your desired font into your web application and enhance its visual appeal.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents